CB-5959: Android: Ensure that directories return size 0
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/2f371d0e Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/2f371d0e Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/2f371d0e Branch: refs/heads/master Commit: 2f371d0ebb5006567450040f7e2bc3417671b828 Parents: 9ac8e47 Author: Ian Clelland <[email protected]> Authored: Fri Feb 7 10:58:02 2014 -0500 Committer: Ian Clelland <[email protected]> Committed: Fri Feb 7 10:58:02 2014 -0500 ---------------------------------------------------------------------- src/android/LocalFilesystem.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/2f371d0e/src/android/LocalFilesystem.java ---------------------------------------------------------------------- diff --git a/src/android/LocalFilesystem.java b/src/android/LocalFilesystem.java index 762f80b..329eac7 100644 --- a/src/android/LocalFilesystem.java +++ b/src/android/LocalFilesystem.java @@ -262,7 +262,8 @@ public class LocalFilesystem extends Filesystem { JSONObject metadata = new JSONObject(); try { - metadata.put("size", file.length()); + // Ensure that directories report a size of 0 + metadata.put("size", file.isDirectory() ? 0 : file.length()); metadata.put("type", FileHelper.getMimeType(file.getAbsolutePath(), cordova)); metadata.put("name", file.getName()); metadata.put("fullPath", inputURL.fullPath);
