apache / apache/cordova-plugin-file

Files dir gets appended an additional /files/ and breaks file storage (FileError {code: 5})

Open
#320 0 comments 0 reactions 0 assignees View on GitHub
bug platform: android
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:
![image](https://user-images.githubusercontent.com/20667544/58506380-900d9500-8165-11e9-953a-fdfce6314867.png)

Which contradicts the documentation:
![image](https://user-images.githubusercontent.com/20667544/58506421-a61b5580-8165-11e9-8198-b58e108de62b.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.