Gallery Preview Files not deleted

Hi everyone!

Is it normal that the gallery preview images (thumbnails) are not being delete, if I delete the actual file via the web interface?


How can I find and delete all those unused preview files?

I’d really appreciate if someone can help me.

There should be an occ option for this:

./occ preview:delete_old

The command

./occ preview:delete_old

only removes the previews from this directoy root/user/thumbnails.
But the gallery preview app saves the thumbnails in the directory root/appdata_appid/preview.
Thumbnails in this directory are not being deleted with this command you have proposed.

Meanwhile I have 6GB of preview data, while only 0,5GB of actual data.

Also, while the app saves the previews in root/appdata_appid/preview, the webinterface seems to ignore those images and creates (the first time i look at the pictures in the web interface) its own previews in this directory root/user/thumbnails.

So all in all, this app seems useless to me

That’s a bit much. @rullzer @nickvergessen is this a bug and should be filed somewhere?

I guess you mixed some things up here:

Which nextcloud, in case gallery app and previewgenerator versions do you use? Nextcloud switched to a new shared previews system, that is forced by the generator and writes previews to appdata_appid/preview. They were directly used by core apps, like files etc. The gallery app on the other hand still created and used previews from user/thumbnails until its official release for nextcloud 12:

  • The generator actually does not create the previews, it just requests them, as other apps (e.g. files) do, and the core system will create and store them on demand.
  1. If you use nextcloud 11 or earlier, the gallery app version supplied by the store does not use the new preview system. In that case you would need to download the newest version directly from github (in case adjust its info.xml), or apply the related pull request manually (see above).

So as the whole nextcloud core switched to the new preview system, the app can’t be useless, as it just requests the core to generate. What is until nextcloud 12 release indeed not fully usable, is the gallery app, as it did not use the cores shared previews, but generates it’s own. And as most people seem to think about the gallery app, by installing the previewgenerator (rather than e.g. the files app, with its small previews), this indeed looks like a generator issue :smiley:.

Looking at the code of the core preview system, previews (inside appdata_appid/preview) will be removed, if their related images are being removed via web interface/clients etc. I guess, if images just move to trash bin, the peviews will stay, until trash retention timeout. What seem to not work yet, is the regular removing of obsolete previews, if the images were removed from outside of nextcloud, directly from the servers file system. For this cases the files index will be cleaned regularly, but the previews not yet. I already opened an issue about that on github.

Also I don’t know hat the “old” gallery app handles it. I guess it will remove it’s “own” previews, if you remove the related images inside the app, but they may stay, if you remove the images inside files app, by client etc. Shared previews should be removed by the gallery app as well, as it also performs a standard file removal.

€: Just du -shc my preview folder: 66 GB for ~100 GB of images.

Thank you for your answer. This makes sense now.

I’m still using version 11.

So the bottom line is, if I upgrade to version 12, the gallery app will use the images in appdata_appid/preview, right? Only issue is deleting unused preview files. Did i get it right?


Yes, just use the delete_old command one more time after upgrade.

But could be still interesting to check the previews size compared to the images size afterwards. If there is still a huge difference not covered by at least added images inside trash bin (and versions?) folders, there should be checked how they are handled and in case how they can be cleaned up.
Also it might be related to the images pixel size. As I get it right, there are always thumbnails created in different width and height up to 2048. If this is also done for small sized pictures, it could explain the higher previews file size and could be discussed if useful. My gallery mostly contains Fotos of ~4k resolution and the previews total file size is significantly smaller as you can see.

I believe in my case the different sizes between preview images and “real” images is caused by a lot of undeleted preview images.

Looking at one single picture, the size ratio of the real image compared to all preview images is similar to yours (~2:1), also in my case.

I just upgraded to Nextcloud 12 and it works now as you have said. The core preview system as well as the gallery saves the previews inside appdata_appid/preview. But I have to disagree with what I’ve quoted above.

Removing a (newly uploaded) file, even from the trash bin, does not delete its previews. Independantly whether the preview was created by the core files app, or by the gallery app. All preview images remain after deleting the actual file. Not even ./occ preview:delete_old causes any unused preview to be deleted :frowning:

Hmm, the “watcher” actually looks like it should do the job. It jumps in on file/folder removal and removes the related file IDs preview folder, as they are named by the file id:

But to be true, I am just a php beginner and might misunderstand the code and also I never checked, if previews on my system do get removed or not. Maybe I will find some time for that tomorrow.

1 Like

I would really appreciate that.

I figured out what is happening, but i can’t tell you why.

It seems as if the preview files are being deleted when deleting the actual file. But at the same time two new preview files are being created.

I recorded my screen. Keep an eye on the file date of the preview files:

I created a new topic here [1], since my initial question has been answered and it’s a different category.

Thank you for helping so far.

[1] File deleted, but preview files are not