Skip to content

Commit

Permalink
New: View size and remove cache and temporary files from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Oct 8, 2023
1 parent 3714c45 commit 8114336
Show file tree
Hide file tree
Showing 21 changed files with 270 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Ignore single folders in browsing [`7507563`](https://github.com/ollm/OpenComic/commit/75075631fcad5fb269427c178e9bac86bc352971)
- Search and filter in library/browsing [`8393903`](https://github.com/ollm/OpenComic/commit/8393903117981bea2b8a79e2e50b77d02334aa05)
- Tracking at the end of the chapter/volume setting option [`39f1954`](https://github.com/ollm/OpenComic/commit/39f19546b2fd363d321f9c423e706c3dc773aa4f)
- View size and remove cache and temporary files from settings

##### 🐛 Bug Fixes

Expand All @@ -29,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Ignore first gamepad and keyboard event in browsing [`9347fbe`](https://github.com/ollm/OpenComic/commit/9347fbe628143e688f956ed0950510a2265c02e2)
- Blurry image when zooming [`0732f3f`](https://github.com/ollm/OpenComic/commit/0732f3f76923f2a50541139e58fb8343e7c20083)
- Progress was not saved in some cases [`964bb64`](https://github.com/ollm/OpenComic/commit/964bb64ee765d3830615e78413bf520b17549b0c)
- Error on opening file in OpenComic [`cb56ccf`](https://github.com/ollm/OpenComic/commit/cb56ccfd032ebfdd60be19a4a9fed82f6b60d0d5)

## [v1.0.0-beta.2](https://github.com/ollm/OpenComic/releases/tag/v1.0.0-beta.2) (03-09-2023)

Expand Down
9 changes: 9 additions & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "Carpetes mestres",
"folder": "Carpeta",
"noFolders": "Sense carpetes"
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "Master folders",
"folder": "Folder",
"noFolders": "No folders"
},
"storage": {
"main": "Storage",
"cache": "Cache",
"cacheDescription": "The thumbnails and index of the compressed files are stored here, it is not recommended to clean it unless it is very large or there is an error related to it",
"clearCache": "Clear cache",
"temporaryFiles": "Temporary files",
"temporaryFilesDescription": "Here the compressed files are decompressed as they are needed, this is automatically deleted when closing OpenComic",
"removeTemporaryFiles": "Remove temporary files"
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "Carpetas maestras",
"folder": "Carpeta",
"noFolders": "Sin carpetas"
},
"storage": {
"main": "Almacenamiento",
"cache": "Caché",
"cacheDescription": "Las miniaturas y el índice de los archivos comprimidos se almacenan aquí, no se recomienda limpiarla a no ser que sea muy grande o haya algún error relacionado con ella",
"clearCache": "Limpiar caché",
"temporaryFiles": "Archivos temporales",
"temporaryFilesDescription": "Aquí se descomprimen los archivos comprimidos a medida que se van necesitando, esto se elimina automáticamente al cerrar OpenComic",
"removeTemporaryFiles": "Eliminar archivos temporales"
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
9 changes: 9 additions & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
"main": "",
"folder": "",
"noFolders": ""
},
"storage": {
"main": "",
"cache": "",
"cacheDescription": "",
"clearCache": "",
"temporaryFiles": "",
"temporaryFilesDescription": "",
"removeTemporaryFiles": ""
}
},
"menu": {
Expand Down
50 changes: 36 additions & 14 deletions scripts/file-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ var file = function(path) {

if(fs.existsSync(path))
{
if(fs.statSync(path).isDirectory())
this.isFolder = true;
else if(inArray(fileExtension(path), compressedExtensions.all))
if(inArray(fileExtension(path), compressedExtensions.all))
this.isCompressed = true;
else if(fs.statSync(path).isDirectory())
this.isFolder = true;
}

return {folder: this.isFolder, compressed: this.isCompressed};
Expand All @@ -59,10 +59,10 @@ var file = function(path) {
}
else
{
if(fs.statSync(_realPath).isDirectory())
files = await this.readDir(path, _realPath);
else if(inArray(fileExtension(path), compressedExtensions.all))
if(inArray(fileExtension(path), compressedExtensions.all))
files = await this.readCompressed(path, _realPath);
else if(fs.statSync(_realPath).isDirectory())
files = await this.readDir(path, _realPath);
}

if(this.config.sort)
Expand Down Expand Up @@ -90,23 +90,25 @@ var file = function(path) {

let _this = this;

return fs.promises.readdir(_realPath).then(function(_files){
return fs.promises.readdir(_realPath, {withFileTypes: !_this.config.fastRead}).then(function(_files){

let files = [];

if(_files)
{
for(let i = 0, len = _files.length; i < len; i++)
{
let filePath = p.join(path, _files[i]);
let name = _this.config.fastRead ? _files[i] : _files[i].name;

let filePath = p.join(path, name);
let retrunPath = filePath;

if(!_this.config.fastRead && fs.statSync(filePath).isDirectory())
files.push({name: _files[i], path: retrunPath, folder: true, compressed: false});
if(!_this.config.fastRead && _files[i].isDirectory())
files.push({name: name, path: retrunPath, folder: true, compressed: false});
else if(inArray(fileExtension(filePath), compressedExtensions.all))
files.push({name: _files[i], path: retrunPath, folder: false, compressed: true});
files.push({name: name, path: retrunPath, folder: false, compressed: true});
else
files.push({name: _files[i], path: retrunPath, folder: false, compressed: false});
files.push({name: name, path: retrunPath, folder: false, compressed: false});
}
}

Expand Down Expand Up @@ -1882,10 +1884,10 @@ function pathType(path)
{
if(inArray(mime.getType(path), compatibleMime))
return {folder: false, compressed: false};
else if(fs.statSync(path).isDirectory())
return {folder: true, compressed: false};
else if(inArray(fileExtension(path), compressedExtensions.all))
return {folder: false, compressed: true};
else if(fs.statSync(path).isDirectory())
return {folder: true, compressed: false};
else
return false;
}
Expand Down Expand Up @@ -1937,6 +1939,25 @@ function sort(files)
}
}

async function dirSize(dir)
{
let files = await fs.promises.readdir(dir, {withFileTypes: true});
let size = 0;

for(let i = 0, len = files.length; i < len; i++)
{
let file = files[i];
let path = p.join(dir, file.name);

if(file.isDirectory())
size += await dirSize(path);
else if(file.isFile())
size += (await fs.promises.stat(path)).size;
}

return size;
}

var prevDevicePixelRatio = window.devicePixelRatio;

window.addEventListener('resize', function() {
Expand Down Expand Up @@ -1965,4 +1986,5 @@ module.exports = {
firstCompressedFile: firstCompressedFile,
lastCompressedFile: lastCompressedFile,
containsCompressed: containsCompressed,
dirSize: dirSize,
}
2 changes: 1 addition & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function createWindow() {
{
appClosing = true;

win.webContents.executeJavaScript('var saved = reading.saveReadingProgress(); removeTemporaryFiles(); saved;', false).then(function(value) {
win.webContents.executeJavaScript('var saved = reading.saveReadingProgress(); settings.removeTemporaryFiles(true); saved;', false).then(function(value) {

if(!value)
win.close();
Expand Down
12 changes: 0 additions & 12 deletions scripts/opencomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,6 @@ function showAboutWindow()
});
}

function removeTemporaryFiles()
{
try
{
fse.emptyDirSync(tempFolder);
}
catch(error)
{
console.error(error);
}
}

function escapeBackSlash(string)
{
return string.replace(/\\+/g, '\\\\');
Expand Down

0 comments on commit 8114336

Please sign in to comment.