Skip to content

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

@mrodal

Description

@mrodal

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:

persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/";

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:

if (!resolvedUri.getEncodedPath().startsWith(rootUriNoTrailingSlash)) {

Its also being returned here without the appended /files/

ret.put("dataDirectory", toDirUrl(context.getFilesDir()));

This is the filesystem on the device:
image

Which contradicts the documentation:
image

Command or Code

Environment, Platform, Device

Android Oreo

Version information

cordova-plugin-file 6.0.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions