Skip to content

fix(SimpleFile): Catch exception and call checkFile() to sanitize broken appdata folder#59981

Open
DerDreschner wants to merge 1 commit intomasterfrom
fix/match-exception-in-files
Open

fix(SimpleFile): Catch exception and call checkFile() to sanitize broken appdata folder#59981
DerDreschner wants to merge 1 commit intomasterfrom
fix/match-exception-in-files

Conversation

@DerDreschner
Copy link
Copy Markdown
Contributor

@DerDreschner DerDreschner commented Apr 28, 2026

Summary

During analyzing of #56510, I realized that broken appdata folders are not handled correctly since version 27 (this commit to be precise).

The issue here is that folders and their files can be listed in the oc_filecache database table, but not exist on filesystem anymore. If that is the case, our wrappers still work correctly as they always prefer the file cache... Until it comes to really read or write to the file system. And here our own putContent() and getContent() methods don't follow the same scheme as their put_file_contents() and get_file_contents() counterparts as we throw an exception instead of returning false.

This change isn't considered on all calls... I can only speak for the preview generation, as that's what I try to fix. The introduction of the oc_previews table fixed the issue there, which means only Nextcloud 32 and older are affected by this bug. But a quick look through the code tells me that there are still a lot more cases that expect false in case of an error, while others already catch an NotFoundException (that's only being thrown when there's no hit against the file cache or method calls like checkPermission() fail... Ohh lord...).

Anyway... With this change, the preview generation will restore the correct appdata structure and starts to generate previews instead of being broken until someone runs occ preview:cleanup manually.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@DerDreschner DerDreschner requested a review from a team as a code owner April 28, 2026 16:56
@DerDreschner DerDreschner requested review from ArtificialOwl and removed request for a team April 28, 2026 16:56
@DerDreschner DerDreschner added 3. to review Waiting for reviews feature: filesystem feature: caching Related to our caching system: scssCacher, jsCombiner... labels Apr 28, 2026
@DerDreschner
Copy link
Copy Markdown
Contributor Author

/backport to stable33

@DerDreschner
Copy link
Copy Markdown
Contributor Author

/backport to stable32

@DerDreschner
Copy link
Copy Markdown
Contributor Author

DerDreschner commented Apr 28, 2026

But a quick look through the code tells me that there are still a lot more cases that expect false in case of an error, while others already catch an NotFoundException (that's only being thrown when there's no hit against the file cache or method calls like checkPermission() fail... Ohh lord...).

Please have a look into the CI pipeline and the failed psalm run. That uncovers the surface of the mess. 😓 Help anyone?

…ken appdata structure

Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner DerDreschner force-pushed the fix/match-exception-in-files branch from dd62131 to 155034c Compare April 29, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Preview Generation Fail - Local Storage

1 participant