Skip to content

Preview generation fails when a cached preview entry references a missing file #63349

Description

@SystemKeeper

⚠️ This issue respects the following points: ⚠️

Bug description

If we end up in the situation that the DB entry exists, but the file does not, we are unable to re-generate the preview via occ, we end up with:

root@nextcloud:/var/www/nextcloud# occ preview:generate 1411721

In LocalPreviewStorage.php line 59:
                                                                                                                            
  Unable to open preview stream at /var/nextcloud/data/appdata_oc4r8rpp6vq8/preview/d/2/c/e/d/1/3/1411721/1024-768-max.jpg  
                                                                                                                            

preview:generate [-s|--size SIZE] [-c|--crop] [-m|--mode MODE] [--] <file>

root@nextcloud:/var/www/nextcloud# vi lib/private/Preview/Storage/LocalPreviewStorage.php 
root@nextcloud:/var/www/nextcloud# occ preview:generate 1411721
#0 /var/www/nextcloud/lib/private/Preview/Storage/StorageFactory.php(32): OC\Preview\Storage\LocalPreviewStorage->readPreview(Object(OC\Preview\Db\Preview))
#1 /var/www/nextcloud/lib/private/Preview/Storage/PreviewFile.php(48): OC\Preview\Storage\StorageFactory->readPreview(Object(OC\Preview\Db\Preview))
#2 /var/www/nextcloud/lib/private/Preview/GeneratorHelper.php(30): OC\Preview\Storage\PreviewFile->getContent()
#3 /var/www/nextcloud/lib/private/Preview/Generator.php(180): OC\Preview\GeneratorHelper->getImage(Object(OC\Preview\Storage\PreviewFile))
#4 /var/www/nextcloud/lib/private/PreviewManager.php(203): OC\Preview\Generator->generatePreviews(Object(OC\Files\Node\File), Array, '...')
#5 /var/www/nextcloud/core/Command/Preview/Generate.php(94): OC\PreviewManager->generatePreviews(Object(OC\Files\Node\File), Array)
#6 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(326): OC\Core\Command\Preview\Generate->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1098): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/nextcloud/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Preview\Generate), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/nextcloud/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/nextcloud/lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/nextcloud/console.php(92): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#12 /var/www/nextcloud/occ(33): require_once('...')

Best case would probably even be automatic handling for that case?

Nextcloud Server version

35 (master)

Activity

  1. added
    0. Needs triage
    on Aug 18, 2026
  2. added theissue type on Aug 18, 2026
  3. lehaplehk commented on Aug 18, 2026

    @lehaplehk

    Good afternoon, I have the same problems when working in a k8s cluster

  4. changed the title [-][Bug]: Preview generation fails when DB entry exists, but local file does not[/-] [+]Preview generation fails when a cached preview entry references a missing file[/+] on Oct 9, 2026
  5. susnux commented on Dec 3, 2026

    @susnux
    Contributor

    Thanks for the report. The fix is in #63486: if the preview row exists but the file is gone, the stale row is deleted and the preview is regenerated. It is approved and waiting to be merged, and backports to stable33–35 have been requested. #63513 and #63821 report the same problem and are closed as duplicates of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triage35-feedbackbugfeature: previews and thumbnailsregression

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions