-
-
Notifications
You must be signed in to change notification settings - Fork 50
feat: expose purgeCache #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great overall. I ran tests against production purging individual objects and folders with 100s of objects and both are working well.
The folder detection is wrong (see other comment) so I get "object not found" for each folder currently, but after that's fixed this should work as expected
|
||
// Extract file paths and filter out folders | ||
const filePaths = objects | ||
.filter((obj) => obj.name && !obj.name.endsWith('/')) // Only files, not folders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name does not in with /
for folders, but folders will have obj.id === null
so use that to check for folders instead.
} | ||
} | ||
|
||
// Process files in batches to avoid overwhelming the API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is no pause between batches this nested loop behaves exactly the same as not doing batching at all. Add a pause after each batch. It should probably be configurable via options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, just as a general note this could take a very long time to run and we should probably make a note that somewhere. Purging 1 object takes between 300ms and 600ms
When I ran this (as-is with no pause between batches) it took 91 seconds to purge a folder containing 221 objects.
What kind of change does this PR introduce?
The goal is to expose the purgeCache operation from the API to the client libraries.
What is the current behavior?
There's no support this in the client libraries.
What is the new behavior?
The goal is to allow this to be exposed in the supabase-js client e.g:
Additional context
Add any other context or screenshots.