Skip to content
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

filesystem(perf): allow deleting entire filesystem in one non-recursive operation #2227

Open
lincolnthree opened this issue Oct 29, 2024 · 0 comments

Comments

@lincolnthree
Copy link

lincolnthree commented Oct 29, 2024

Feature Request

Plugin

Filesystem

Description

Currently, at least on the Web implementation of the FIlesystem plugin, it appears that the only way to delete the contents of a filesystem path is to delete the entire IndexedDB manually. Unless I am missing something.

There is of course the rmdir('/', { recursive: true }) operation, but this appears to iterate through every entry very very very slowly. If there are a significant number of entries, this operation can take minutes to finish.

It would be nice if there were a clear() operation, or if the existin delete allowed a more efficient operation.

Platform(s)

Web (Ios/Android optional as those seem much faster, but for parity I would assume you'd want it on all platforms.)

Preferred Solution

Either make rmdir more efficient on Web, or provide a clear() operation that deletes the database entirely on Web, and on other platforms it would clear the specified FilesystemDirectory.

Alternatives

Not sure, open to suggestions.

I suppose you could use open an IndexedDB handle on web, then issue a delete operation using the key value, instead of using recursion:
https://github.com/ionic-team/capacitor-plugins/blob/main/filesystem/src/web.ts#L357

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants