File deleted, but preview files are not

I’m running Nextcloud 12 on Ubuntu and I figured out that when I delete a file (i.e. a picture) its preview files are not being deleted.

Well, let’s put it this way… It seems like they are being deleted, but at the same time, some new preview files are being created.

I recorded my screen to show you what is going on.
In the video I’m going to upload a picture, then I’m going to look at the previews so that those are created and then I delete the file again. Simultaniously I keep an eye on the appdata_appid/preview folder. Watch the preview folder/file dates, then you’ll see what I mean.

Best Regards!

Can anybody reproduce this behavior? Is it a bug? How can i officially report this bug? On github?

Sorry, I’m very new to all of this, but willing to invest some effort too :slight_smile:

Hi @lukasb314,

GitHub is indeed the place to do it. It may be something for @rullzer to check, but to begin with you could pop it in:

Have a quick search of the forum too, this has been discussed in a couple of topics and a GH Issue may already exist.

I found an issue on github treating this:

1 Like

The issue was about a possible regular cleaning job, if some images is being NOT deleted via Nextcloud webui/client. Because there is one that cleans the file database, but I did not find some hint in the code that previews will be cleaned as well with it.

But the issue you found suggests that there is an additional problem, IF the images are removed regularly. I did not find the time to reproduce it so far. Is there a way to easily find out about a files id? In address field (opening something in files app) I see some id, but it seems to be one of the folder (and no related entry in previews folder) not the file itself.

Would be also interesting to know, how images, removed just to trash bin are handled, if their id stays the same and previews stay until trash bin clearing or not.

I agree, it’s not fully the same topic.

I created a new issue, as I couldn’t find an appropriate one:

1 Like

Could it be that this topic is still not solved or is a problem now again?
I made some tests with my newly installed nextcloud 18.0.3.

  1. Upload an image
  2. Use one of the two methods to create the preview of the file:
  • Browse nextcloud directory of uploaded file
  • Use preview generator app to generate previews with occ command (sudo -u nginx php /srv/www/nextcloud/occ preview:pre-generate) which will process the entry in the table oc_preview_generation that was created by uploading the file
  1. Have a look into the directory /srv/www/nextcloud/data/appdata_XXXXXXXX/preview. There is a directory named after the fileid (from ‘oc_filecache’ table) with the previews of the image.
  2. Delete the file in the web interface and also delete it in the trashbin of the webinterface.
  3. Wait for the cron job to run or run it manually by using e.g. systemctl start nextcloudcron.service (when the setup is done with systemd like descriped here:
    This point is quite interesting, because I didn’t yet understand 100% how this works. There is the table oc_jobs with all the defined background tasks. One of them is OC\Preview\BackgroundCleanupJob. According to some github conversations I think this one should be responsible for deleting the obsolete file previews. I’ve also set the last_run to 0 and then startet the cron manually to force the execution of this task.
  4. My expected behavior is, that the obsolete file previews are delete. But if I browse /srv/www/nextcloud/data/appdata_XXXXXXXX/preview the files are still there. Also in the table oc_filecache The entries are not deleted… Only the ID 3745 which was the entry for the actual file has been deleted.

What is going on here? Is this still an issues for all nextcloud instances or only on my configuration? Can someone of you test it with your setup and let me know?


Best regards

A lot of sources that I found regarding this topic:

1 Like

I have set the the log to “debug” and I get the following messages:
[no app in context] Debug: Deprecated event type for \OCP\Files::postDelete: Symfony\Component\EventDispatcher\GenericEvent
at 2020-03-29T21:20:34+02:00
[no app in context] Debug: Deprecated event type for \OCP\Files::preDelete: Symfony\Component\EventDispatcher\GenericEvent
at 2020-03-29T21:20:34+02:00

I guess this should not yet be a problem?

Sorry for bothering you. It seams to work now. I guess it was a timing problem in the beginning because this scheduled task for the “preview garbage collection” is only set to run once per our in the php code:
So I have been too unpatient and obviously made a mistake because normally it already should have run after I set the table entry last_run to 0.

1 Like