Open alx-tuilmenau opened 4 months ago
@alx-tuilmenau I totally agree with you. IMHO, there is a possible optimization for your proposal, instead of deleting all previews "pass due" at once, delete groups of 50/100/300 images every cron execution in order to decrease filesystem/DB stress.
Eventually, DB+filesystem will be "clean" without collateral issues. Most NC instances will have hundreds of users and thousands of previews...
@rdlab-upc of course, and this should be done during the maintenance time set in config. I discovered it first because I had to wait a long time for re-organizing the underlying filesystem (for other reasons) and noticed it needed days for the preview folder. My ugly cleanup script needed about half a day to delete ca. 300k images and 400k folders older than 1 year (but the storage is on Nearline HDDs, so it's not fast).
In the meantime, would you be willing to share your "ugly" script?
I was already thinking about this when I made the first post. The script (for CLI) probably only fits my environment and needs to be modified if you want to use it yourself. It assumes that mysql is used, the mimetype of a folder is 2, the table prefix is "oc_". The storage numeric_id of the folder with the previews must be entered at the beginning. And, it only works with a file storage. And apart from config.php, no APIs from Nextcloud are used. Maybe it will break something, be careful, have a backup.
@alx-tuilmenau thank you for sharing your script to demonstrate the concept.
I appreciate this feature request and am wondering if it would be worthwhile to consider using a preview file's atime rather than the mtime stored in the database. While it would certainly be more intensive, it would handle the case of a frequently accessed preview file, even if it may have been created a long time ago.
@amessina I have no atime, because the filesystem is mounted with noatime option for performance reasons. See my proposal in the first post for this. So maybe a other solution is to use find in the appdata folder to create a list of files (and maybe deleting the files and use a second find to find, list and delete the empty folders) and using these lists to find and delete the database entries (or use occ files:scan-app-data , but I cant use this, this will take weeks).
How to use GitHub
Is your feature request related to a problem? Please describe. There are a lot of issues here targeting the grow of the preview folder in appdata.. I would suggest a mechanism to add a expire date for it.
Describe the solution you'd like
Describe alternatives you've considered At the moment, I use an ugly external script to delete images, oc_filecache entries and empty folders of preview images older then 12 months.