ionic-team / ionic-team/capacitor-filesystem

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

Open
#42 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6
Forks
15
Avg merge
14m
Merged PRs (30d)
1

Description

## 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 https://github.com/ionic-team/capacitor-filesystem/issues/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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.