"failed to open stream: No such file or directory" in logs during preview generation, only a fraction of previews generated

Since I upgraded from NextCloud 18.0 to 21.0 (and with it, the Preview Generator app) preview generation is very cumbersome. After dozens of repeatedly tried preview:generate-all (pre-generate has no effect), only about 20% of the stored images get previews. There are hundreds of errors in nextcloud.log like the one below. What could be the issue?

The output with the -vvv option is just [object Object].

"file_put_contents(/ncdata/appdata_435c912d3565e/preview/f/1/3/8/e/2/b/88492/2048-1536-max.jpg): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#278

1 Like

So, the problem was that when I wanted to regenerate previews, I simply erased the contents of appdata_XXX/preview. Every preview file is also stored in the DB so this alone causes problems. On one hand NC will not find the previews it thought to exist, on the other PreviewGenerator will not generate new files (as it’s thought to exist as per db).

So anyone finding this issue - if you want to clear previews, either:

  • delete the preview folder contents, then run occ files:scan-app-data - this syncs files/db
  • faster/riskier: delete the contents of the DB with SQL like delete from oc_filecache where path like 'appdata_ocpb8d7vbr73/preview/%';

More resources:

1 Like