Skip to content

filesystem: Allow specifying custom IndexedDB name on Web and/or default to provided Directory name in IndexedDB name #42

@lincolnthree

Description

@lincolnthree

Feature Request

Plugin

Filesystem

Description

Currently, the filesystem plugin operates on the "Disc" IndexedDB directory. However there is no way to change or customize this. It would be nice to specify the database to operate on when making calls into the plugin. Alternatively you could use the FilesystemDirectory argument as the database name/suffix.

Disc_EXTERNAL, etc.

This is related to #41

Platform(s)

Web

Preferred Solution

Allow passing webDBName (or rootDirName or whatever you want to call it) as a parameter to API methods on the Filesystem plugin. Relevant operations could even automatically create the folder on ios and Android.

filesystem.mkdir({
  directory: Directory.Cache,
  path:  'IMAGE-CACHE'
  webDBName: 'cache_1'
};

// creates IndexedDB.Disc_cache_1 database

Ideally in addition to this, or -- at a minimum, the IndexedDB database name should default to the directory provided:

filesystem.mkdir({
  directory: Directory.Cache,
  path:  'IMAGE-CACHE'
};

// creates IndexedDB.Disc_CACHE database

Alternatives

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

Essentially, it's impossible to clear "just one path" in a very large virtual filesystem directory on Web in a performant manner. Since the rmdir operation is recursive and has to iterate all entries, this is a VERY slow operation and is fairly painful for the user to wait for on Web platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions