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: Allow specifying custom IndexedDB name on Web and/or default to provided Directory name in IndexedDB name #2228

Open
lincolnthree opened this issue Oct 29, 2024 · 0 comments
Labels
platform: web type: feature request A new feature, enhancement, or improvement

Comments

@lincolnthree
Copy link

lincolnthree commented Oct 29, 2024

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 #2227

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.

@ionitron-bot ionitron-bot bot added the triage label Oct 29, 2024
@ionitron-bot ionitron-bot bot removed the triage label Oct 29, 2024
@alexgerardojacinto alexgerardojacinto added the type: feature request A new feature, enhancement, or improvement label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: web type: feature request A new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

3 participants