diff --git a/core/AppInfo/ConfigLexicon.php b/core/AppInfo/ConfigLexicon.php index 5d1f7269347..508a090e8a4 100644 --- a/core/AppInfo/ConfigLexicon.php +++ b/core/AppInfo/ConfigLexicon.php @@ -38,6 +38,8 @@ class ConfigLexicon implements ILexicon { public const LASTCRON_TIMESTAMP = 'lastcron'; + public const ON_DEMAND_PREVIEW_MIGRATION = 'on_demand_preview_migration'; + public function getStrictness(): Strictness { return Strictness::IGNORE; } @@ -93,6 +95,12 @@ class ConfigLexicon implements ILexicon { new Entry(self::OCM_INVITE_ACCEPT_DIALOG, ValueType::STRING, '', 'route to local invite accept dialog', note: 'set as empty string to disable feature'), new Entry(self::UNIFIED_SEARCH_MIN_SEARCH_LENGTH, ValueType::INT, 1, 'Minimum search length to trigger the request', rename: 'unified-search.min-search-length'), new Entry(self::UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST, ValueType::INT, 25, 'Maximum results returned per search request', rename: 'unified-search.max-results-per-request'), + new Entry( + key: self::ON_DEMAND_PREVIEW_MIGRATION, + type: ValueType::BOOL, + defaultRaw: true, + definition: 'Whether on demand preview migration is enabled.' + ), ]; } diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 1ceff60d54b..4627fad93b2 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -6,6 +6,7 @@ */ namespace OC\Preview; +use OC\Core\AppInfo\ConfigLexicon; use OC\Preview\Db\Preview; use OC\Preview\Db\PreviewMapper; use OC\Preview\Storage\PreviewFile; @@ -111,7 +112,7 @@ class Generator { [$file->getId() => $previews] = $this->previewMapper->getAvailablePreviews([$file->getId()]); - if (empty($previews)) { + if (empty($previews) && $this->appConfig->getValueBool('core', ConfigLexicon::ON_DEMAND_PREVIEW_MIGRATION)) { $previews = $this->migrateOldPreviews($file->getId()); } @@ -201,7 +202,7 @@ class Generator { } /** - * @return array + * @return Preview[] */ private function migrateOldPreviews(int $fileId): array { if ($this->appConfig->getValueBool('core', 'previewMovedDone')) {