Previews folder not populating after deletion of previews

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 34.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu server 26.04
  • Web server and version (e.g, Apache 2.4.25):
    • nginx/1.28.3 (Ubuntu)
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx/1.28.3
  • PHP version (e.g, 8.3):
    • 8.5.4
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • Just now
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare metal
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Yes

Summary of the issue you are facing:

After deleting the preview folders within appdata, running occ files:scann-app-data, and then running occ preview:generate-all, the directory does not populate at all despite encountering no errors with the -vvv flag.

Steps to replicate it (hint: details matter!):

  1. Delete previews folders in appdata_/preview while nginx isn’t running.

  2. Run ‘sudo -u www-data php /var/www/cloud/occ files:scan-app-data’

  3. Start nginx

  4. Run ‘sudo -u www-data php /var/www/cloud/occ preview:generate-all -vvv’

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

{"reqId":"wWpF6MfAiwNEWWI8W853","level":3,"time":"2026-08-01T09:46:35+00:00","remoteAddr":"162.158.19.63","user":"mgomez","app":"index","method":"GET","url":"/core/preview?fileId=22032&x=128&y=128&mimeFallback=true&v=398c23&a=0","scriptName":"/index.php","message":"Unable to open preview stream at /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/7/f/6/4/1/1/f/22032/256-256-crop.jpg","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0","version":"34.0.2.1","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"Unable to open preview stream at /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/7/f/6/4/1/1/f/22032/256-256-crop.jpg","Code":0,"Trace":[{"file":"/var/www/cloud/lib/private/Preview/Storage/StorageFactory.php","line":33,"function":"readPreview","class":"OC\\Preview\\Storage\\LocalPreviewStorage","type":"->"},{"file":"/var/www/cloud/lib/private/Preview/Storage/PreviewFile.php","line":74,"function":"readPreview","class":"OC\\Preview\\Storage\\StorageFactory","type":"->"},{"file":"/var/www/cloud/lib/public/AppFramework/Http/FileDisplayResponse.php","line":53,"function":"read","class":"OC\\Preview\\Storage\\PreviewFile","type":"->"},{"file":"/var/www/cloud/lib/private/AppFramework/App.php","line":194,"function":"callback","class":"OCP\\AppFramework\\Http\\FileDisplayResponse","type":"->"},{"file":"/var/www/cloud/lib/private/Route/Router.php","line":324,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/cloud/lib/base.php","line":1172,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/cloud/index.php","line":25,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/cloud/lib/private/Preview/Storage/LocalPreviewStorage.php","Line":60,"message":"Unable to open preview stream at /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/7/f/6/4/1/1/f/22032/256-256-crop.jpg","exception":"{\"class\":\"OCP\\Files\\NotFoundException\",\"message\":\"Unable to open preview stream at /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/7/f/6/4/1/1/f/22032/256-256-crop.jpg\",\"code\":0,\"file\":\"/var/www/cloud/lib/private/Preview/Storage/LocalPreviewStorage.php:60\",\"trace\":\"#0 /var/www/cloud/lib/private/Preview/Storage/StorageFactory.php(33): OC\\Preview\\Storage\\LocalPreviewStorage->readPreview()\\n#1 /var/www/cloud/lib/private/Preview/Storage/PreviewFile.php(74): OC\\Preview\\Storage\\StorageFactory->readPreview()\\n#2 /var/www/cloud/lib/public/AppFramework/Http/FileDisplayResponse.php(53): OC\\Preview\\Storage\\PreviewFile->read()\\n#3 /var/www/cloud/lib/private/AppFramework/App.php(194): OCP\\AppFramework\\Http\\FileDisplayResponse->callback()\\n#4 /var/www/cloud/lib/private/Route/Router.php(324): OC\\AppFramework\\App::main()\\n#5 /var/www/cloud/lib/base.php(1172): OC\\Route\\Router->match()\\n#6 /var/www/cloud/index.php(25): OC::handleRequest()\\n#7 {main}\"}","CustomMessage":"Unable to open preview stream at /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/7/f/6/4/1/1/f/22032/256-256-crop.jpg"},"id":"6a6dc6a72afa9"}

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.gomezconsulting.ovh"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "34.0.2.1",
        "overwrite.cli.url": "https:\/\/cloud.gomezconsulting.ovh",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "enable_previews": true,
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "maintenance": false,
        "app_install_overwrite": [],
        "loglevel": 2,
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/cloud\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/cloud\/apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe"
    }
}

Apps

Enabled:

  • activity: 7.0.0
  • app_api: 34.0.0
  • appstore: 1.0.0
  • bruteforcesettings: 7.0.0
  • circles: 34.0.0
  • cloud_federation_api: 1.18.0
  • comments: 1.24.0
  • contactsinteraction: 1.15.0
  • cookbook: 0.11.9
  • dashboard: 7.14.0
  • dav: 1.39.0
  • federatedfilesharing: 1.24.0
  • federation: 1.24.0
  • files: 2.6.0
  • files_downloadlimit: 5.2.0
  • files_external: 1.26.0
  • files_lock: 34.0.1
  • files_reminders: 1.7.0
  • files_sharing: 1.26.0
  • files_trashbin: 1.24.0
  • files_versions: 1.27.0
  • firstrunwizard: 7.0.0-dev.0
  • logreader: 7.0.0
  • lookup_server_connector: 1.22.0
  • news: 28.6.0
  • nextcloud_announcements: 6.0.0
  • notifications: 7.0.0-dev.1
  • oauth2: 1.22.0
  • office: 1.0.0
  • password_policy: 6.0.0-dev.0
  • photos: 7.0.0
  • previewgenerator: 5.14.0
  • privacy: 6.0.0-dev.1
  • profile: 1.3.0
  • provisioning_api: 1.24.0
  • recommendations: 7.0.0
  • related_resources: 5.0.0-dev.0
  • richdocuments: 11.1.0
  • serverinfo: 6.0.0
  • settings: 1.17.0
  • sharebymail: 1.24.0
  • support: 6.0.0
  • survey_client: 6.0.0-dev.0
  • systemtags: 1.24.0
  • tasks: 0.18.1
  • text: 8.0.0
  • theming: 2.9.0
  • twofactor_backupcodes: 1.23.0
  • twofactor_totp: 16.0.0
  • updatenotification: 1.24.0
  • user_status: 1.14.0
  • viewer: 7.0.0-dev.0
  • weather_status: 1.14.0
  • webhook_listeners: 1.6.0
  • workflowengine: 2.16.0
    Disabled:
  • admin_audit: 1.24.0
  • encryption: 2.22.0
  • files_pdfviewer: 7.0.0-dev.0 (installed 7.0.0-dev.0)
  • suspicious_login: 12.0.0-dev.0
  • twofactor_nextcloud_notification: 8.0.0
  • user_ldap: 1.25.0

@Hi @mgomez,

one detail in the error path stands out to me:

The smbshare in that mount point makes me suspect your whole data directory - including appdata_<instanceid>/preview/ - lives on an SMB/CIFS mount. If that’s the case, it would be my prime suspect here: preview:generate-all finishes without an error (so the write appears to succeed), but the follow-up read fails with Unable to open preview stream … LocalPreviewStorage.php:60. That “write reports success, but reopening it immediately fails” pattern is exactly the kind of thing CIFS attribute/metadata caching and its different locking semantics can cause - something a local POSIX filesystem simply never shows.

Before guessing further, could you confirm a couple of things for me?

  1. Is the data directory (and with it appdata_<instanceid>/preview/) actually on a CIFS/SMB mount?
  2. Was it on that share from the very first install, or was the data directory moved onto it at some later point?
  3. How exactly is the share mounted? The matching /etc/fstab line or mount command, with all of its options.
  4. In particular the caching and ownership options: actimeo, cache=, and uid=/gid=/file_mode=/dir_mode=.

These would give us everything in one go:

mount | grep smbshare
grep smbshare /etc/fstab
ls -la /mnt/smbshare/DATA/appdata_ockcgxrdv2hs/preview/

And one quick cross-check that would confirm or rule out the mount as the cause: temporarily point the appdata (or the whole data directory) at local storage and run preview:generate-all again. If previews populate fine there, the CIFS mount is the culprit and we can dig into the mount options from there.

Thanks!


ernolf

I am pretty certain that the smb share is mounted with some proper permissions for the drive to be written to and read by www-data. I have put www-data in the users group. Whether that’s a good practice security-wise is another matter lol.

The data folder was always installed to this share.

Here is the output of the cmds:

//192.168.0.5/share on /mnt/smbshare type cifs (rw,relatime,vers=1.0,cache=strict,upcall_target=app,username=admin,uid=33,forceuid,gid=100,forcegid,addr=192.168.0.5,file_mode=0770,dir_mode=0770,iocharset=utf8,soft,nounix,serverino,mapposix,mfsymlinks,reparse=nfs,nativesocket,symlink=mfsymlinks,rsize=61440,wsize=65536,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1)

The output of grep smbshare /etc/fstab:

//192.168.0.5/share /mnt/smbshare cifs rw,mfsymlinks,credentials=/home/miguel/credentials,iocharset=utf8,uid=33,gid=100,file_mode=0770,dir_mode=0770,vers=1.0      0       0

The output of ls -la…etc:

drwxrwx--- - www-data  1 Aug 18:23  .
drwxrwx--- - www-data  3 Jul 00:43  ..

It’s worth noting something I forgot to mention. I have successfully used preview:generate-all command, but because I wanted to regenerate them with “preview_max_x” of 300, I deleted the contents of the folder. However regenerating fails for some reason, even when using occ files:scan-app-data.

I can’t fathom what could be going wrong here.

P.S. Another addition: I managed to repopulate some contents when I downloaded files, deleted them from nextcloud, and uploaded them again.

Hi @mgomez

Why did you choose vers=1.0? That is a very old SMB dialect (SMB1), deprecated for years. Is your Samba server really that old?


ernolf

Although my nas works with SMBv2, it somehow performs slower. So I just keep it in LAN with SMBv1. The server and my PC can touch it, and that’s it.

Please use the supported command (since v30) instead: occ preview:cleanup.