apache / apache/cordova-plugin-file
Files dir gets appended an additional /files/ and breaks file storage (FileError {code: 5})
- Dominant language
- JavaScript
- Stars
- 744
- Forks
- 754
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
# Bug Report
## Problem
I cant create files
### What is expected to happen?
To be able to create files
### What does actually happen?
I cant, I get FileError {code: 5}
## Information
This line is the culprit:
https://github.com/apache/cordova-plugin-file/blob/c609ff6f59d23d0bcbfe92c5eb81665e3df41027/src/android/FileUtils.java#L189
getFilesDir() already returns the path with `/files`, and its being added again for some reason.
This makes the rootUri of the persistent filesystem to reject every file in the `/files/` directory in this line:
https://github.com/apache/cordova-plugin-file/blob/c609ff6f59d23d0bcbfe92c5eb81665e3df41027/src/android/LocalFilesystem.java#L83
Its also being returned here without the appended `/files/`
https://github.com/apache/cordova-plugin-file/blob/c609ff6f59d23d0bcbfe92c5eb81665e3df41027/src/android/FileUtils.java#L993
This is the filesystem on the device:

Which contradicts the documentation:

### Command or Code
### Environment, Platform, Device
Android Oreo
### Version information
cordova-plugin-file 6.0.1
## Checklist
- [X] I searched for existing GitHub issues
- [X] I updated all Cordova tooling to most recent version
- [ ] I included all the necessary information above
Contributor guide
Research direction
Read src/android/FileUtils.java around lines 189 and 993, then src/android/LocalFilesystem.java around line 83; compare getFilesDir() with the documented device layout. Reproduce file creation on Android Oreo and verify that the persistent filesystem accepts files under /files/ without the duplicated path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100