cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <>
Subject [jira] [Commented] (CB-9752) getDirectory fails on valid directory with assets filesystem
Date Wed, 04 Nov 2015 18:30:28 GMT


ASF subversion and git services commented on CB-9752:

Commit 76c8fd5e43598ea660c2db64eb08e2659b45a575 in cordova-plugin-file's branch refs/heads/master
from [~jasongin]
[;h=76c8fd5 ]

Fix CB-9752: getDirectory fails on valid directory with assets filesystem

Calls to FileEntry.getDirectory() on an asset entry would internally call
the AssetFileSystem.listAssets() method using an asset path with a
trailing slash, regardless of whether a trailing slash was included by
the user. But neither the asset list cache (from cdvasset.manifest) nor
Android's AssetManager.list() API support matching a path with a trailing
slash. That resulted in a TypeMismatchException thrown from
AssetFileSystem.getFileForLocalURL(), because the asset path was found
but not matched as a directory as expected by the caller.

This fix removes the trailing slash from the asset path before matching
against the asset list cache or calling Android's AssetManager.list() API.
A new unit test for getting asset directories fails without and passes
with the fix.

While I'm here, I'm also adding a unit test for reading asset file
contents. There are a couple old bug reports about that (CB-7273,
CB-8350). The bugs don't repro anymore, but I'm adding the test anyway
since there wasn't good test coverage before.

> getDirectory fails on valid directory with assets filesystem
> ------------------------------------------------------------
>                 Key: CB-9752
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File
>         Environment: cordova 5.3.3
> cordova android 4.0.0
> cordova-plugin-file 2.0.0
> *** using build-extras.gradle to speed up lookups (as per for plugin) ***
>            Reporter: Denis Babineau
>            Assignee: Jason Ginchereau
> The following JS snippet fails with "failed to get www directory":
> window.resolveLocalFileSystemURL(cordova.file.applicationDirectory, function(appDir)
>     appDir.getDirectory('www', {create:false}, function(wwwDir) {
>         console.log("success!");
>     }, function() {
>         console.log("failed to get www directory");
>     });
> }, function() {
>     console.log("Failed to get application directory");
> });
> I narrowed it down to's listAssets() method called from isDirectory()
which returns the "new String[0];" (assetPath = 'www/' in this method) which in turn causes
isDirectory() to return false.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message