binarynonsense / comic-book-reader

ACBR - A comic book reader and converter for CBZ, CBR, CB7, EPUB and PDF files (Windows & Linux)
BSD 2-Clause "Simplified" License
170 stars 8 forks source link

Minor Bug regarding automatic cache clearing #71

Closed trzyglow closed 1 year ago

trzyglow commented 1 year ago

After exiting the program, the following error message shows up: js_abcr_error

it only shows after exiting the program for the first time, and it's not related to something that breaks anything. just wanted to let you know about this issue, if you weren't already aware of it (since it could potentially throw some people off).

binarynonsense commented 1 year ago

Thanks for the bug report! It doesn't happen on any of my test machines, so I'll have to take a look at the code and figure out what could cause it and why am I not catching the error. I moved the cleanup code and tweaked it a little since the previous version, so if it wasn't happening to you with that one that may be a clue to see where to start.

trzyglow commented 1 year ago

it also happens in the previous version; maybe it has something to do with it being installed on my secondary drive.

trzyglow commented 1 year ago

yup, checked it on my main drive and a seperate machine (also main drive) and the error doesn't appear.

binarynonsense commented 1 year ago

Yes, that's what I was thinking reading the stack in the screenshot. I'm making a new build that catches the error, I'll let you know when it's available so you can tell me if it works.

binarynonsense commented 1 year ago

I've uploaded a new version, let me know if it keeps happening.

trzyglow commented 1 year ago

it's fixed now

binarynonsense commented 1 year ago

Good, thanks for letting me know about the bug so quickly, it's one of those that leaves a bad impression. Now I have to figure out what's happening exactly, as I'm still not able to replicate it. I tried running it from a pendrive, should be the same as a different hard drive for this, but it doesn't happen. I know some of the files I try to delete during the cleanup sometimes can't be deleted (I go a bit overboard because in my case I don't mind electron having to rebuild them every time if it means leaving the user disk cleaner, but they are not meant to be deleted when quitting), so if you run it in dev mode (--dev argument) you can always see some delete fails. But in your case seems like a different error (EPERM), so I have to figure out if this could affect other situations where I have to delete folders, mainly the temp folders I create. If you have the time, could you check if ACBR is leaving stuff in the temp folder (subfolders with a name starting with "acbr-")? Make a conversion for example so it has to create and clean up one. You can check the temp folder path in the preferences (Advanced section). You can also run ACBR from the command line with the --dev argument to see some extra info.

trzyglow commented 1 year ago

did some conversions, and checked the temp folders before, during and after the conversion; all works seamlessly regarding the cached folder deletion.

binarynonsense commented 1 year ago

Great! I was hoping that was the case and the problem was only with the electron files cleanup and me forgetting to catch it for file deletions (I was only catching the error for folders). I still don't know why only in some cases and between different drives some of those files raise an error (EPERM) of not having the permissions to delete them (I would expect it to happen in every computer sometimes or not at all...) but who knows, as long as it is limited to that fringe situation, which I already expected to have some problems like that, I'm happy :) Thanks for your help!

trzyglow commented 1 year ago

ran it with devmode, and noticed that it only deleted the folder with the cached images, not the other (small in size) caches.

devmode log: [18:17:20] [DEBUG] dev mode: true [18:17:20] [DEBUG] release version: true [18:18:40] [DEBUG] deleted folder: C:\Users\timoh\AppData\Local\Temp\acbr-TPqZiW [18:18:53] settings saved to: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\acbr-player.cfg [18:18:53] playlist saved to: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\acbr-player.m3u [18:18:53] settings saved to: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\acbr.cfg [18:18:53] history saved to: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\acbr.hst [18:18:53] cleaning up... [18:18:53] [ERROR] Error: ENOTEMPTY at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:232:11) [18:18:53] [ERROR] couldn't delete folder: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\DawnCache at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:233:11) [18:18:53] [ERROR] Error: ENOTEMPTY at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:232:11) [18:18:53] [ERROR] couldn't delete folder: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\GPUCache at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:233:11) [18:18:53] [ERROR] Error: ENOTEMPTY at deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:232:11) [18:18:53] [ERROR] couldn't delete folder: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\Local Storage\leveldb at deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:233:11) [18:18:53] [ERROR] Error: ENOTEMPTY at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:232:11) [18:18:53] [ERROR] couldn't delete folder: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\Local Storage at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:233:11) [18:18:53] [ERROR] Error: ENOTEMPTY at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:232:11) [18:18:53] [ERROR] couldn't delete folder: C:\Users\timoh\AppData\Roaming\acbr-comic-book-reader\Session Storage at Object.deleteFolderRecursive (D:\Software\Comic Book Reader\resources\app.asar\src\shared\main\file-utils.js:233:11)

binarynonsense commented 1 year ago

Yes, that's "normal". Those are things that usually refuse to be deleted :) but a lot of the chromium stuff that electron usually leaves in there, and could end up taking a few hundred MBs before I started doing this, is now cleaned up.