Skip to content

fix(files_external): clean up filecache when deleting an external storage - #64173

Open
solracsf wants to merge 1 commit into
masterfrom
fix/7312-external-storage-filecache-cleanup
Open

fix(files_external): clean up filecache when deleting an external storage#64173
solracsf wants to merge 1 commit into
masterfrom
fix/7312-external-storage-filecache-cleanup

Conversation

@solracsf

@solracsf solracsf commented Sep 10, 2026

Copy link
Copy Markdown
Member

Related to #7312. This fixes the part where removed external storages leave their filecache rows behind, not the table fragmentation discussed there.

Since 33.0.0 (c80c980), StorageDeletedEvent is dispatched before Storage::cleanByMountId(). MountCacheService reacts to it by deleting the storage's oc_mounts rows, which are exactly what cleanByMountId() uses to find the storages, so the oc_filecache and oc_storages rows stay. occ files:cleanup doesn't pick them up either, because the storage row still exists.

The event now fires after the cleanup, so its listeners no longer see the deleted storage's cache and storage rows. In server only MountCacheService listens, and it doesn't need them.

Rows that were already orphaned on 33 and 34 are not cleaned up by this change. stable33 and stable34 are affected; stable32 doesn't have the event.

…rage

StoragesService::removeStorage() dispatched StorageDeletedEvent before
Storage::cleanByMountId(). MountCacheService handles that event by
removing the storage's oc_mounts rows, and cleanByMountId() looks the
storages up through those rows, so it found nothing and left the
oc_filecache and oc_storages rows behind. occ files:cleanup cannot
recover them because the oc_storages row still exists.

Dispatch the event after the cleanup, which restores the order used
before the event was introduced.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf requested a review from a team as a code owner September 10, 2026 10:13
@solracsf
solracsf requested review from Altahrim, come-nc, icewind1991 and salmart-dev and removed request for a team September 10, 2026 10:13
@solracsf solracsf added this to the Nextcloud 36 milestone Sep 10, 2026
@solracsf

Copy link
Copy Markdown
Member Author

/backport to stable35

@solracsf

Copy link
Copy Markdown
Member Author

/backport to stable34

@solracsf

Copy link
Copy Markdown
Member Author

/backport to stable33

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.

2 participants