Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/BackgroundJobs/PreviewMigrationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ 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;
}

$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;
}
Expand Down
12 changes: 10 additions & 2 deletions lib/private/Preview/PreviewMigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}

Expand Down
Loading