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

Web - Filesystem mkdir recursive bug #2231

Open
maitre-piccolo opened this issue Nov 3, 2024 · 0 comments
Open

Web - Filesystem mkdir recursive bug #2231

maitre-piccolo opened this issue Nov 3, 2024 · 0 comments

Comments

@maitre-piccolo
Copy link

Bug Report

Plugin(s)

filesystem 6.0.1

Capacitor Version

  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2
  @capacitor/ios: 6.1.2

Platform(s)

Web

Current Behavior

When using the filesystem mkdir command with the recursive argument and a 3 segments path (see example below), this raises the exception "Cannot create Root directory"

Expected Behavior

No exception

Code Reproduction

Just call this line in any capacitor web project :

await Filesystem.mkdir({'path':/LIBRARY/A/B, recursive:true});

It's important that the folder path has at least 3 segments.

Other Technical Details

Additional Context

This is the current capacitor filesystem mkdir web function : mkdir_orig.txt

The issue seems to be with this line :

const parentArgPath = parentPath.substr(parentPath.indexOf('/', 1));

This call gets the parent path of what is already the parent path. So basically, the mkdir function skips a level. If you have a folder with 3 segments, it goes directly from the 3 segments path to a 1 segment path, the function is never called with a depth of 2 (which is the recursive break condition), hence the exception.

The simple fix seem to use the already existing parentPath as is in the recursive call of mkdir, like this : mkdir_changed.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants