fix(preview): regenerate previews whose stored file is gone - #63486
fix(preview): regenerate previews whose stored file is gone#63486rayvincent2 wants to merge 1 commit into
Conversation
When a preview row exists in the database but the backing file is missing, preview:generate failed with NotFoundException from LocalPreviewStorage::readPreview. Drop the stale row and generate a new preview instead so occ preview:generate and preview:generate-all can repair as they run. Fixes: nextcloud#63349 Assisted-by: Grok:grok-4.6 Signed-off-by: Ray Vincent <rayhvincent@gmail.com>
f4090ea to
2e23e9c
Compare
|
Follow-up to the live-test note in the description: I have now run a path-scoped Context: I had already completed successful docker exec -u www-data -e PHP_MEMORY_LIMIT=2G nextcloud-manual_install-nextcloud \
php -d memory_limit=2G /var/www/html/occ preview:generate-all -vv \
--path "/ray/files/Photos/My Photos/2026"Results for /ray/files/Photos/My Photos/2026:
So this is a smoke / regression check that preview:generate-all still walks the tree cleanly with the patch applied when previews are already present. The original bug (DB row present, preview file missing → hard fail on readPreview) was verified earlier with single-file preview:generate on known-broken rows. I still have not live-tested object-store primary storage. |
| 'store' => $store, | ||
| ] = $this->getObjectStoreInfoForExistingPreview($preview); | ||
|
|
||
| return $store->objectExists($urn); |
There was a problem hiding this comment.
this generates network requests, which is not great for performance. I wonder if for object store we could just always return true (at least for now until a better solution is found)
Summary
If a preview database row exists but the stored file is gone, generation used that row and then failed when it tried to read the file.
Generatornow checks that the file is still present, deletes the stale row if it is not, and regenerates the preview. That covers a missing max preview and missing extra sizes when several sizes are configured for one file.Unit tests cover local storage, object storage, and multiple sizes per file.
Live test: I applied this change on a Nextcloud 34.0.3 instance with local preview storage.
occ preview:generatehad been failing withNotFoundExceptionfromLocalPreviewStorage::readPreview(DB row for1535-2048-max.jpg, file missing). After the change the same command succeeded. Several other images were in the same state. Opening them in Memories requested previews again and those thumbnails regenerated instead of staying broken.I have not live-tested object store
or a full.preview:generate-allre-runChecklist
3. to review, feature component)stable32)AI (if applicable)
I used Grok to implement the fix and tests; I reviewed the diff, ran the unit tests, and verified it on 34.0.3.