Skip to content

Commit 07db3f6

Browse files
committed
fix(preview): Be a bit more verbose when failing to migrate previews
Signed-off-by: Carl Schwan <carl@carlschwan.eu> Assisted-by: ClaudeCode:claude-sonnet-5
1 parent 0664e32 commit 07db3f6

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎core/BackgroundJobs/PreviewMigrationJob.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,20 @@ protected function run(mixed $argument): void {
4545

4646
$storage = $this->rootFolder->getMountPoint()->getStorage();
4747
if ($storage === null) {
48+
$this->logger->warning('Preview migration skipped: the root mount point has no storage.');
4849
$this->appConfig->setValueBool('core', 'previewMovedDone', true);
4950
return;
5051
}
5152

5253
$cache = $storage->getCache();
5354
$previewRootId = $cache->getId(rtrim($this->previewRootPath, '/'));
5455
if ($previewRootId === -1) {
55-
// No previews have ever been generated on this instance.
56+
// No previews were ever generated, or the storage config no longer
57+
// matches the one the filecache data was recorded under.
58+
$this->logger->warning('Preview migration skipped: no preview root found at "{path}" on storage "{storageId}".', [
59+
'path' => $this->previewRootPath,
60+
'storageId' => $storage->getId(),
61+
]);
5662
$this->appConfig->setValueBool('core', 'previewMovedDone', true);
5763
return;
5864
}

‎lib/private/Preview/PreviewMigrationService.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,25 @@ public function migrateFileId(int $fileId, bool $flatPath, ?array $entries = nul
135135
}
136136
} else {
137137
// No matching fileId, delete the orphaned preview files themselves.
138+
$transactionStarted = false;
138139
try {
139140
$folder = $this->appData->getFolder($internalPath);
140141
$this->connection->beginTransaction();
142+
$transactionStarted = true;
141143
foreach ($folder->getDirectoryListing() as $file) {
142144
$file->delete();
143145
}
144146
$this->connection->commit();
145147
} catch (NotFoundException) {
146148
// Folder already gone, nothing to clean up.
147-
} catch (Exception) {
148-
$this->connection->rollback();
149+
} catch (\Throwable $e) {
150+
// Also catches non-DB failures from $file->delete(), e.g. an unreachable objectstore.
151+
if ($transactionStarted) {
152+
$this->connection->rollback();
153+
}
154+
$this->logger->error('Unable to delete orphaned preview at ' . $internalPath, [
155+
'exception' => $e,
156+
]);
149157
}
150158
}
151159

0 commit comments

Comments
 (0)