Skip to content

feat(preview): honor enabledPreviewProviders as generation try-order - #64648

Open
skjnldsv wants to merge 1 commit into
nextcloud:masterfrom
skjnldsv:feature/preview-provider-try-order
Open

skjnldsv wants to merge 1 commit into
nextcloud:masterfrom
skjnldsv:feature/preview-provider-try-order

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Split out of #63796 per review discussion there (splitting the combined admin-UI + provider-ordering + failures work into separate scoped PRs). This is the provider-ordering half, no UI attached. The admin settings page in #63796 will be rebased on top of this once it's split out too.

relates to #63795

enabledPreviewProviders currently only acts as a whitelist: order in the array doesn't matter, and PreviewManager::getProviders() sorts by regex string length. This PR makes the array order the generation try-order instead. registerProviderClosure() now keeps the registering class name, and PreviewManager rebuilds the provider map on each getProviders() call so foreach order follows the index of each class in enabledPreviewProviders (registration order for anything not listed, so unconfigured instances see no behavior change).

Generator::generateProviderPreview() collects matching providers into the new order first, then tries them in sequence. It also now catches \Throwable around getThumbnail() so a provider that throws (missing binary, corrupt file, whatever) is skipped in favor of the next provider instead of aborting the whole preview attempt. Flagging the broad catch for review: this used to let exceptions from providers propagate, so if anything currently relies on that propagation this is a behavior change.

When enabledPreviewProviders is unset, the computed default now prefers Imaginary first if preview_imaginary_url is configured, with native HEIC appended as a fallback when Imagick supports it, instead of always defaulting to the plain native list. Same config keys and types as before, just a smarter unset-default.

The shared default/recommended provider list logic lives in a new PreviewProviderDefaults (lib/private/Preview), pulled out so the admin settings page PR can reuse it instead of duplicating the provider list literals.

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

@skjnldsv
skjnldsv requested a review from a team as a code owner September 22, 2026 11:20
@skjnldsv skjnldsv added enhancement 3. to review Waiting for reviews labels Sep 22, 2026
@skjnldsv
skjnldsv requested review from Altahrim, come-nc, icewind1991 and leftybournes and removed request for a team September 22, 2026 11:20
Split out of nextcloud#63796. Providers registered via registerProviderClosure()
now keep their class name, and PreviewManager rebuilds the provider map
on each getProviders() call so foreach order follows the index of each
class in enabledPreviewProviders (registration order for anything not
listed). Generator::generateProviderPreview() collects matches first to
preserve that order, then wraps getThumbnail() in a try/catch so one
throwing provider is skipped in favor of the next instead of aborting
generation.

When enabledPreviewProviders is unset, the computed default now prefers
Imaginary first if preview_imaginary_url is configured, with native HEIC
appended as a fallback when Imagick supports it. The shared default/
recommended provider lists live in the new PreviewProviderDefaults so
the upcoming admin settings page (PR B) can reuse them without
duplicating the provider list literals.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv
skjnldsv force-pushed the feature/preview-provider-try-order branch from 2739721 to 119547e Compare September 30, 2026 07:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant