Skip to content

fix(files): Continue scanning after StorageInvalidException - #65585

Open
DerDreschner wants to merge 1 commit into
masterfrom
fix/prevent-crash-on-stale-fed-shares
Open

DerDreschner wants to merge 1 commit into
masterfrom
fix/prevent-crash-on-stale-fed-shares

Conversation

@DerDreschner

Copy link
Copy Markdown
Member

Summary

When a federated share was already removed on the remote end, accessing it triggers a StorageInvalidException after the share and its mount are removed locally. When running occ files:scan, this exception isn't caught by the scanner and aborts the scan of all remaining mounts of that user, printing a stack trace instead. This can be pretty frustrating on larger instances with many federated shares.

To avoid that, the StorageInvalidException is now caught and handled the same way as the StorageNotAvailableException: log it as an error, report it through the StorageNotAvailable hook and continue with the next mount.

Checklist

AI (if applicable)

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

When a federated share was already removed on the remote end, accessing it triggers a `StorageInvalidException` after the share and its mount are removed locally. When running `occ files:scan`, this exception isn't caught by the scanner and aborts the scan of all remaining mounts of that user, printing a stack trace instead. This can be pretty frustrating on larger instances with many federated shares.

To avoid that, the `StorageInvalidException` is now caught and handled the same way as the `StorageNotAvailableException`: log it as an error, report it through the `StorageNotAvailable` hook and continue with the next mount.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner DerDreschner self-assigned this Oct 16, 2026
@DerDreschner
DerDreschner requested a review from a team as a code owner October 16, 2026 14:34
@DerDreschner
DerDreschner requested review from Altahrim, provokateurin, salmart-dev and sorbaugh and removed request for a team October 16, 2026 14:34
@DerDreschner
DerDreschner requested review from come-nc and a balanced review from Copilot October 27, 2026 06:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow exception-handling change updates both consumers and includes focused regression coverage, with no blocking issues identified in static review; tests were not executed.

No open issues 🎉

What changed in this PR

This PR prevents invalid storage, such as a deleted federated share, from stopping scans of a user’s remaining mounts.

Changes:

  • Handle StorageInvalidException like unavailable storage: log it, emit the existing hook, and continue scanning.
  • Update both scan command listeners to accept the additional exception type.
  • Add regression tests for scan continuation and app-data error reporting.
File Description
tests/​lib/​Files/​Utils/​ScannerTest.php Verify logging, hook emission, and scanning of subsequent mounts.
lib/​private/​Files/​Utils/​Scanner.php Catch invalid-storage exceptions within the mount scan loop.
apps/​files/​tests/​Command/​ScanAppDataTest.php Verify invalid-storage errors are reported by the app-data command.
apps/​files/​lib/​Command/​ScanAppData.php Accept invalid-storage exceptions in the error listener.
apps/​files/​lib/​Command/​Scan.php Accept invalid-storage exceptions in the error-counting listener.

Review effort: Balanced

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

occ files:scan crashes on stale federated shares after remote deletion

4 participants