Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: optimize prefix triggers (#supabase34257) #645

Closed

Conversation

catcoon33
Copy link

What kind of change does this PR introduce?

Bug fix, this fixes a "ghost" directory issue

What is the current behavior?

checkout this issue:
#supabase34257

Screen.Recording.2025-03-24.at.23.11.50.mov

When renaming a folder (by updating an object's path), the old prefix remains in the storage.prefixes table even after all objects have been moved out of it. This creates a "ghost" directory that:

  • Still appears in directory listings
  • Has no actual objects inside it
  • Creates confusion for users
  • Pollutes the storage hierarchy

What is the new behavior?

  • Added a cleanup of old prefixes when renaming objects

Additional context

Screen.Recording.2025-03-24.at.23.04.37.mov

Add any other context or screenshots.

@fenos
Copy link
Contributor

fenos commented Apr 9, 2025

Hey @catcoon33. Thanks a lot for this; it is an elegant solution to the problem!
I'll include this fix in another PR because we cannot change existing migrations.

I offer a massive thanks for this!

@fenos fenos closed this Apr 9, 2025
@fenos
Copy link
Contributor

fenos commented Apr 9, 2025

For reference, i've improved this further, and optimised the deletes with a CTE
https://github.com/supabase/storage/pull/644/files#diff-e757d9e5b3619862081b16a587fc4974659d078314f5faf9992c7307aad021bfR103-R138

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants