Nextcloud missing image previews

I recently upgraded to Nextcloud 16.0.3 and I noticed a couple issues after that. After the upgrade my appdata directory went totally kaput and I had to restore from the ZFS snapshot I took before the update, since I didn’t notice until days later that the update broke some things. Now I’m realizing images previews are messed up. For context:

OS: FreeBSD 12.0
Webserver: nginx 1.16
PHP: 7.3

Things I’ve tried:

  • occ repair command
  • preview:delete_old
  • generate all previews all over again
  • Cleared browser cache

No dice. I’m thinking maybe I could just nuke the entire preview directory and start anew, but it’s nearly 10GB, and though I’m fine with doing so if that’s the solution, just wanted to see if anyone else has a better idea?

EDIT: I forgot to paste in the nextcloud.log error:

    "app": "PHP",
    "level": 3,
    "message": "touch(): Unable to create file /mnt/nc_data/appdata_ocjsh3o40umv/preview/39188/4096-2728-max.jpg because No such file or directory at /usr/local/www/nginx-dist/nextcloud/lib/private/Files/Storage/Local.php#207",
    "method": "GET",
    "remoteAddr": "",
    "reqId": "",
    "time": "2019-08-05T10:05:00-07:00",
    "url": "/core/preview?fileId=39188&c=ec4147eedfd99264ae40bf76d53ffa11&x=250&y=250&forceIcon=0",
    "user": "stratacast",
    "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0",
    "version": ""

The " 39188" directory indeed does not exist

There was a thread a couple of weeks ago, which dealt with NC and previews in a general sense. The blog post was this:

Since I was curious, I also gave it a spin and deleted the contents of my preview folder competely and had the previews re-generated with the “optimized” settings. That did what is was supposed to do and as long as there’s nothing wrong with your appdata folder, a simple re-generate should do it for you as well.

In theory my appdata folder is good…I think. After the previously mentioned debacle I wonder what else the updater may have messed up (or if it even was that, but I’m never digging into my appdata dir). It was restored from a working state from 16.0.1 where none of my issues were present, albeit, there was a 2-3 day gap in between me restoring the older appdata. So far it’s been these preview issues and my app store directory was just flat out missing

I think I’ll nuke my previews and try the optimized settings and report back

No dice there I’m afraid. It’s still looking in all the wrong places

I did get an error when generating image previews this time though:

2019-08-05T15:29:26-07:00 In Availability.php line 79:
2019-08-05T15:29:26-07:00   [OCP\Files\StorageNotAvailableException (1)]  

Not sure why this would be, my ownership is right and hasn’t been been chowned or anything for years. Something really must have whacked out my appdata with that update

Trying again but this time I wiped out the oc_filecache with records like appdata_the_id/preview as well as nuking the contents of the preview dir again to see if that might be my solution. Generating all previews all over again. If this doesn’t work, then I don’t know what will. I can’t view most of my images on Nextcloud right now unless I download them

Have you tried running

occ files:scan-appdata

after deleting all the old previews from the preview folder?

Yes, I did try that and it did nothing. What was going on was the entries in the oc_filecache table were not matching what was in the filesystem, so I had to wipe out the previews directory again, delete all the contents in that table pertaining to appdata_id/preview and then rebuild my previews again, and it’s all goo!

rm -rf /path/to/appdata_id_here/preview

And then inside the database:
DELETE FROM oc_filecache where path like 'appdata_id_here/preview/%';

Then rebuild the previews:
sudo -u www /usr/local/www/nginx/nextcloud/occ preview:generate-all

I am really struggling with this. I followed all your steps and some more from here and here. I can’t seem to get any previews to work. This has been a problem ever since my server updated to NC22.

My oc_filecache database is 165MB in size but when executing delete from oc_filecache where path LIKE 'appdata_%/preview/%'; zero rows are affected.
Edit: By replacing % with * it still says zero rows affected but the table shrunk to <60MB. After generating all previews again it still does not work, sadly.

I have a problem with the preview-images too since i upgraded to 22…

Do you have these log-entries too?:

Verursacht durch Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘configvalue + 1) WHERE (userid = ‘USERNAME’) AND (configkey = ‘read’) AND (…’ at line 1