ionic-team / ionic-team/capacitor-filesystem
filesystem(perf): allow deleting entire filesystem in one non-recursive operation
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 15
- Avg merge
- 14m
- Merged PRs (30d)
- 1
Description
## 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
Contributor guide
Assessment
This issue has not been assessed yet.