From 07db3f6b68422ac5577e26685270c0ab44a34c12 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 4 Sep 2026 10:57:13 +0200 Subject: [PATCH] fix(preview): Be a bit more verbose when failing to migrate previews Signed-off-by: Carl Schwan Assisted-by: ClaudeCode:claude-sonnet-5 --- core/BackgroundJobs/PreviewMigrationJob.php | 8 +++++++- lib/private/Preview/PreviewMigrationService.php | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/BackgroundJobs/PreviewMigrationJob.php b/core/BackgroundJobs/PreviewMigrationJob.php index e5bd2b4a49450..45f71e561244f 100644 --- a/core/BackgroundJobs/PreviewMigrationJob.php +++ b/core/BackgroundJobs/PreviewMigrationJob.php @@ -45,6 +45,7 @@ protected function run(mixed $argument): void { $storage = $this->rootFolder->getMountPoint()->getStorage(); if ($storage === null) { + $this->logger->warning('Preview migration skipped: the root mount point has no storage.'); $this->appConfig->setValueBool('core', 'previewMovedDone', true); return; } @@ -52,7 +53,12 @@ protected function run(mixed $argument): void { $cache = $storage->getCache(); $previewRootId = $cache->getId(rtrim($this->previewRootPath, '/')); if ($previewRootId === -1) { - // No previews have ever been generated on this instance. + // No previews were ever generated, or the storage config no longer + // matches the one the filecache data was recorded under. + $this->logger->warning('Preview migration skipped: no preview root found at "{path}" on storage "{storageId}".', [ + 'path' => $this->previewRootPath, + 'storageId' => $storage->getId(), + ]); $this->appConfig->setValueBool('core', 'previewMovedDone', true); return; } diff --git a/lib/private/Preview/PreviewMigrationService.php b/lib/private/Preview/PreviewMigrationService.php index 377950da84952..31529cbe2f02b 100644 --- a/lib/private/Preview/PreviewMigrationService.php +++ b/lib/private/Preview/PreviewMigrationService.php @@ -135,17 +135,25 @@ public function migrateFileId(int $fileId, bool $flatPath, ?array $entries = nul } } else { // No matching fileId, delete the orphaned preview files themselves. + $transactionStarted = false; try { $folder = $this->appData->getFolder($internalPath); $this->connection->beginTransaction(); + $transactionStarted = true; foreach ($folder->getDirectoryListing() as $file) { $file->delete(); } $this->connection->commit(); } catch (NotFoundException) { // Folder already gone, nothing to clean up. - } catch (Exception) { - $this->connection->rollback(); + } catch (\Throwable $e) { + // Also catches non-DB failures from $file->delete(), e.g. an unreachable objectstore. + if ($transactionStarted) { + $this->connection->rollback(); + } + $this->logger->error('Unable to delete orphaned preview at ' . $internalPath, [ + 'exception' => $e, + ]); } }