Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- Nextcloud Server is running on 64bit capable CPU, PHP and OS.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
For some of my photos, no preview in no size will be generated.
I have ~60k photos in my Nextcloud file store. For most photos, the previews are generated and they work well in every app.
However, there is a bunch of photos where no previews are generated and they will not be displayed by content in any app -- of course they are shown as files without previews.
The metadata of the photos is shown on the details tab, so it's not a general file access issue.
After some investigation through the logs I think I have discovered that for these photos the preview folder is not generated correctly. The log message points to folders of this structure:
/.../nextcloud/data/appdata_xxxx/preview/284054/1536-2048-max.jpg
while it should be of this structure:
/.../nextcloud/data/appdata_xxxx/preview/5/6/4/0/1/4/1/0/284054/1536-2048-max.jpg
According to my investigations, the responsible code is found in server/lib/private/Preview/Storage/Root.php
, function public function getFolder(string $name): ISimpleFolder
.
Why does this code fail for some files while it doesn't for all the others?!?
What can I do to resolve this issue?!?
Steps to reproduce
- If only I knew...
- Use my photo collection
occ preview:generate-all
- Click on "broken" photo in "files" app
(the photo itself of course is not broken, it is clean when I open it in any program on Windows or Linux -- I tried many)
Expected behavior
- in the "files" app, a small preview icon is shown
- after clicking on the photo, a large preview is shown
Both doesn't happen.
- a placeholder icon is shown
- "The image cannot be loaded" is shown
Installation method
Community Manual installation with Archive
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Apache (supported)
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
# sudo -u www-data php /mnt/data/var/www/nextcloud/occ config:list system
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"x.y.z",
"x",
"192.168.1.1"
],
"overwrite.cli.url": "https:\/\/x.y.z\/nextcloud",
"htaccess.RewriteBase": "\/nextcloud",
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "25.0.3.2",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"memcache.local": "\\OC\\Memcache\\Redis",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379
},
"filelocking.enabled": true,
"mail_smtpmode": "smtp",
"mail_smtpsecure": "tls",
"mail_sendmailmode": "smtp",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpauthtype": "LOGIN",
"mail_smtpauth": 1,
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "587",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"maintenance": false,
"loglevel": 0,
"app_install_overwrite": [
"bookmarks_fulltextsearch",
"quickaccesssorting",
"ocr",
"files_downloadactivity",
"checksum",
"audioplayer_editor",
"epubreader",
"gpxmotion",
"previewgenerator",
"audioplayer_sonos",
"camerarawpreviews",
"apporder",
"duplicatefinder",
"files_markdown",
"talked",
"video_converter",
"extract",
"files_ebookreader",
"talk_simple_poll"
],
"loglevel:9": "",
"preview_max_x": "2048",
"preview_max_y": "2048",
"preview_max_memory": 4096,
"preview_max_filesize_image": 256,
"jpeg_quality": "60",
"enabledPreviewProviders": [
"OC\\Preview\\Image",
"OC\\Preview\\HEIC",
"OC\\Preview\\TIFF",
"OC\\Preview\\Movie",
"OC\\Preview\\MKV",
"OC\\Preview\\MP4",
"OC\\Preview\\AVI"
],
"theme": "",
"ldapIgnoreNamingRules": false,
"ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
"default_phone_region": "DE",
"trashbin_retention_obligation": "90, auto",
"memories.exiftool": "\/mnt\/data\/var\/www\/nextcloud\/apps\/memories\/exiftool-bin\/exiftool-amd64-glibc",
"memories.ffmpeg_path": "\/usr\/bin\/ffmpeg",
"memories.ffprobe_path": "\/usr\/bin\/ffprobe",
"memories.transcoder": "\/mnt\/data\/var\/www\/nextcloud\/apps\/memories\/exiftool-bin\/go-vod-amd64",
"memories.no_transcode": false,
"memories.qsv": true
}
}
List of activated Apps
# sudo -u www-data php /mnt/data/var/www/nextcloud/occ app:list
Enabled:
- activity: 2.17.0
- admin_audit: 1.15.0
- audioplayer: 3.3.1
- bookmarks: 12.0.0
- bruteforcesettings: 2.5.0
- calendar: 4.2.2
- camerarawpreviews: 0.8.0
- checksum: 1.2.0
- circles: 25.0.0
- cloud_federation_api: 1.8.0
- cloud_py_api: 0.1.4
- comments: 1.15.0
- contacts: 5.0.3
- contactsinteraction: 1.6.0
- dashboard: 7.5.0
- dav: 1.24.0
- deck: 1.8.3
- event_update_notification: 2.0.0
- external: 5.0.0
- extract: 1.3.5
- federatedfilesharing: 1.15.0
- federation: 1.15.0
- files: 1.20.1
- files_downloadactivity: 1.15.0
- files_external: 1.17.0
- files_fulltextsearch: 25.0.0
- files_fulltextsearch_tesseract: 25.0.0
- files_markdown: 2.3.6
- files_mindmap: 0.0.27
- files_pdfviewer: 2.6.0
- files_rightclick: 1.4.0
- files_sharing: 1.17.0
- files_trashbin: 1.15.0
- files_versions: 1.18.0
- firstrunwizard: 2.14.0
- flow_notifications: 1.5.0
- fulltextsearch: 25.0.0
- fulltextsearch_elasticsearch: 25.0.0
- gpxmotion: 0.1.0
- gpxpod: 5.0.4
- groupfolders: 13.1.0
- logreader: 2.10.0
- lookup_server_connector: 1.13.0
- mail: 2.2.2
- maps: 0.2.4
- mediadc: 0.3.3
- memories: 4.10.3
- metadata: 0.17.0
- music: 1.8.1
- news: 20.0.1
- nextcloud_announcements: 1.14.0
- notes: 4.6.0
- notifications: 2.13.1
- oauth2: 1.13.0
- password_policy: 1.15.0
- passwords: 2023.1.23
- photos: 2.0.1
- previewgenerator: 5.1.1
- privacy: 1.9.0
- provisioning_api: 1.15.0
- quickaccesssorting: 1.1.4
- recommendations: 1.4.0
- related_resources: 1.0.4
- richdocuments: 7.1.0
- serverinfo: 1.15.0
- settings: 1.7.0
- sharebymail: 1.15.0
- side_menu: 3.5.2
- spreed: 15.0.3
- support: 1.8.0
- survey_client: 1.13.0
- suspicious_login: 4.3.0
- systemtags: 1.15.0
- talked: 0.4.0
- tasks: 0.14.5
- text: 3.6.0
- theming: 2.0.1
- twofactor_backupcodes: 1.14.0
- updatenotification: 1.15.0
- user_status: 1.5.0
- video_converter: 1.0.5
- viewer: 1.9.0
- weather_status: 1.5.0
- welcome: 1.0.6
- workflow_ocr: 1.25.3
- workflowengine: 2.7.0
Disabled:
- audioplayer_editor: 0.3.0
- audioplayer_sonos: 1.3.0
- bookmarks_fulltextsearch: 1.2.0
- duplicatefinder: 0.0.15
- encryption
- epubreader: 1.4.7
- facerecognition: 0.9.5
- files_antivirus: 4.0.2
- ransomware_protection: 1.14.0
- recognize: 3.3.6
- twofactor_totp
- user_ldap: 1.10.2
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"WZAyV8M8jHYZHTrLtOVG","level":3,"time":"2023-01-31T19:23:00+00:00","remoteAddr":"2a02:560:56ac:2a00:e1b0:b437:9572:eb8d","user":"aaa","app":"PHP","method":"GET","url":"/nextcloud/core/preview?fileId=284057&c=2f7c0b38ddf242dcddb5fd0e6d13be55&x=375&y=375&forceIcon=0&a=0","message":"file_put_contents(/.../nextcloud/data/appdata_xxxxx/preview/284057/1536-2048-max.jpg): Failed to open stream: No such file or directory at /.../nextcloud/lib/private/Files/Storage/Local.php#311","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0","version":"25.0.3.2","exception":{"Exception":"Error","Message":"file_put_contents(/.../nextcloud/data/appdata_xxxxx/preview/284057/1536-2048-max.jpg): Failed to open stream: No such file or directory at /.../nextcloud/lib/private/Files/Storage/Local.php#311","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/.../nextcloud/lib/private/Files/Storage/Local.php","line":311,"function":"file_put_contents"},{"file":"/.../nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":258,"function":"file_put_contents","class":"OC\\Files\\Storage\\Local","type":"->"},{"file":"/.../nextcloud/lib/private/Files/View.php","line":1179,"function":"file_put_contents","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->"},{"file":"/.../nextcloud/lib/private/Files/View.php","line":705,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/.../nextcloud/lib/private/Files/Node/Folder.php","line":192,"function":"file_put_contents","class":"OC\\Files\\View","type":"->"},{"file":"/.../nextcloud/lib/private/Files/SimpleFS/NewSimpleFile.php","line":121,"function":"newFile","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/.../nextcloud/lib/private/Preview/Generator.php","line":363,"function":"putContent","class":"OC\\Files\\SimpleFS\\NewSimpleFile","type":"->"},{"file":"/.../nextcloud/lib/private/Preview/Generator.php","line":162,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/.../nextcloud/lib/private/Preview/Generator.php","line":114,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->"},{"file":"/.../nextcloud/lib/private/PreviewManager.php","line":185,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->"},{"file":"/.../nextcloud/core/Controller/PreviewController.php","line":144,"function":"getPreview","class":"OC\\PreviewManager","type":"->"},{"file":"/.../nextcloud/core/Controller/PreviewController.php","line":113,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/.../nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->"},{"file":"/.../nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/.../nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/.../nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/.../nextcloud/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/.../nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/.../nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"63d96a950405a"}
The same message formatted:
[PHP] Fehler: Error: file_put_contents(/.../nextcloud/data/appdata_xxxxx/preview/284054/1536-2048-max.jpg): Failed to open stream: No such file or directory at /.../nextcloud/lib/private/Files/Storage/Local.php#311 at <>
- <>
OC\Log\ErrorHandler::onError() - /.../nextcloud/lib/private/Files/Storage/Local.php line 311
file_put_contents() - /.../nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 258
OC\Files\Storage\Local->file_put_contents() - /.../nextcloud/lib/private/Files/View.php line 1179
OC\Files\Storage\Wrapper\Wrapper->file_put_contents() - /..../nextcloud/lib/private/Files/View.php line 705
OC\Files\View->basicOperation() - /..../nextcloud/lib/private/Files/Node/Folder.php line 192
OC\Files\View->file_put_contents() - /.../nextcloud/lib/private/Files/SimpleFS/NewSimpleFile.php line 121
OC\Files\Node\Folder->newFile() - /.../nextcloud/lib/private/Preview/Generator.php line 363
OC\Files\SimpleFS\NewSimpleFile->putContent() - /.../nextcloud/lib/private/Preview/Generator.php line 162
OC\Preview\Generator->getMaxPreview() - /.../nextcloud/lib/private/Preview/Generator.php line 114
OC\Preview\Generator->generatePreviews() - /.../nextcloud/lib/private/PreviewManager.php line 185
OC\Preview\Generator->getPreview() - /.../nextcloud/core/Controller/PreviewController.php line 144
OC\PreviewManager->getPreview() - /.../nextcloud/core/Controller/PreviewController.php line 113
OC\Core\Controller\PreviewController->fetchPreview() - /.../nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
OC\Core\Controller\PreviewController->getPreviewByFileId() - /.../nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
OC\AppFramework\Http\Dispatcher->executeController() - /..../nextcloud/lib/private/AppFramework/App.php line 172
OC\AppFramework\Http\Dispatcher->dispatch() - /.../nextcloud/lib/private/Route/Router.php line 298
OC\AppFramework\App::main() - /.../nextcloud/lib/base.php line 1047
OC\Route\Router->match() - /.../nextcloud/index.php line 36
OC::handleRequest()
GET /nextcloud/core/preview?fileId=284054&c=46f47f6cce3eee1cb4d3653abfd7b9d4&x=375&y=375&forceIcon=0&a=0
from 2a02:560:56ac:2a00:e1b0:b437:9572:eb8d by thomas at 2023-01-31T19:32:33+00:00
### Additional info
_No response_