filesystem(perf): allow deleting entire filesystem in one non-recursive operation #2227
Labels
platform: android
platform: ios
platform: web
type: feature request
A new feature, enhancement, or improvement
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 existindelete
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 aclear()
operation that deletes the database entirely on Web, and on other platforms it would clear the specifiedFilesystemDirectory
.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
The text was updated successfully, but these errors were encountered: