What is the appdata_ocpom4nckwru directory?

Hi,

I noticed on my nextcloud installation that in my data directory there are not only directories for my user but also a directory called appdata_ocpom4nckwru with the following sub-directories:

drwxr-xr-x    2 www-data www-data 4096 Apr 17 23:00 appstore
drwxr-xr-x   31 www-data www-data 4096 Aug 18 15:32 avatar
drwxr-xr-x 1624 www-data www-data 4096 Aug 21 02:13 preview
drwxr-xr-x    3 www-data www-data 4096 Apr 17 22:55 theming

So I want to know what exactly this directory is for? I have the impression that it is used for temporary files. For example the preview dir is full of PNG files generated by the preview app.

It does not seem to be automatically cleaned. Can I simply delete the whole directory from time to time, for example every months?

Best,
H.N.

2 Likes

Its a quick fix to keep app related data (such as configuratin files or caching) in data/

since data/ has user ids as sub folders, adding an appdata folder would make a user appdata owner of that directory. So they simply append a random hash at the end.

Thanks for your explanation, that makes sense.

Now is it possible like to trash the whole directory every month part of a crontab entry? I noticed the content just gets bigger and bigger with time, especially because of the preview app.

Or is there a way from Nextcloud in order to clean this directory regularly and not leave it growing for nothing?

At least for previews and updater you could clean it, but especially for previews I would not recommend it. They will be cleaned, as the related image files get deleted, and for the others you want the huge performance speed they give in webui. If you dont need previews, then deactivate them in config.php, so none will be created.

About the other folders I am not quite sure what is stored there and if only there. Would be e.g. possible that all users need to reupload their avatars, if you remove that folder.

Deleting the folder can break things so I wouldn’t do that. Just upgrade your storage?

There is a preview directory inside that appdata directory which has over 20k PNG temporary files using approximately 5 GB for caching purpose and I really don’t see the point of adding more storage just so that directory can grow indefinitely for useless PNG cache files. There must be a better solution for that. IMHO this directory requires an automatic cleaning solution maybe through the occ cron where one can define a time to keep, for example only keep 1 month of temporary preview files.

1 Like

The previews are just not intended to be “temporary” so far. They will be created on demand for every image file in different dimensions (depending on requested for file list, details, gallery app etc) and will stay there until the image file is removed. All previews for one image can have around the same size than the image itself, depending on the original image size of course. So the folder cannot grow “unlimited” and you have a rough idea what the maximum size (all previews for all images are created) will be.

Discussions around that preview function so far went into the opposite direction. People found the preview generation on files app and especially gallery app too slow, as long as there are not yet previews generated. If you upload a new gallery from holiday and want to share it e.g. to friends/family, they will face a relatively slow online experience, until all previews were generated. Therefore the preview generator app was release, so all previews for all images can be pregenerated e.g. over night or before you share the image folder to others. So I didn’t yet found the idea to have those previews removed (for still existing images) after certain time :smile:.

If you don’t need the whole preview thing, you can deactivate the feature through your config.php as mentioned, but of course also the previews on demand will be not generated anymore.
An interesting feature would be for fast hardware to just create the previews on demand, but not save them on the harddrive.

As solution for you I could imagine a cron job, that daily scans the previews folder for subfolders (related to single files) that were created > 30 days ago or what. Should be not too difficult.

Thanks for your detailed explanation, it makes sense as it gives a better user experience. Still I would expect to see a parameter in the config.php file of Nextcloud where one could define for how long to keep the preview files, then the occ cron could take care of cleaning up. Should not be too difficult neither :wink:

I deleted that appdata folder and got no backup of it… (deleted it and overwrote all backups with the new stuff)

Is there any way to fix it? I just see a white screen now with:

"Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log."

Edit: Was able to fix it with this here: Screwed up data/appdata_instanceid

We experienced a problem with the preview folder growing too big - once your preview folder has about 65,000 entries, you cannot create any more directories and any attempt to view an image via the browser results in an error. Seems that a clean up process would be useful to avoid this problem.

For nc 20, there seems to be much more in the appdata_<random> folder, at least when using the nextcloud docker image. As the ‘more’ includes js, and css folder, this is a (potential) problem, see Setting NEXTCLOUD_DATA_DIR · Issue #1396 · nextcloud/docker · GitHub .