Skip to content

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

Open
@lincolnthree

Description

@lincolnthree

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions