Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7469818A36 for ; Fri, 30 Oct 2015 20:56:28 +0000 (UTC) Received: (qmail 69805 invoked by uid 500); 30 Oct 2015 20:56:28 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 69683 invoked by uid 500); 30 Oct 2015 20:56:28 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 69628 invoked by uid 99); 30 Oct 2015 20:56:27 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2015 20:56:27 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D01572C1F5B for ; Fri, 30 Oct 2015 20:56:27 +0000 (UTC) Date: Fri, 30 Oct 2015 20:56:27 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-7253) window.requestFileSystem fails when no sd card is present and non-zero value is provided for size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-7253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14983297#comment-14983297 ] ASF GitHub Bot commented on CB-7253: ------------------------------------ GitHub user jasongin opened a pull request: https://github.com/apache/cordova-plugin-file/pull/145 CB-7253: requestFileSystem fails when no external storage is present There were 2 issues behind this bug: 1) DirectoryManager.getFreeDiskSpace() used an incorrect way of checking the free internal storage space: using a path of "/" would always result in 0 reported free space. 2) When checking whether requested space was available, the requestFileSystem() method would always check the external storage space and fallback to internal storage space, regardless of what type of filesystem (external, internal, or other) was being requested. To fix both of these issues, I've added a new getFreeSpaceInBytes() method on the FileSystem base class, which is called on the actual filesystem instance being retrieved by requestFileSystem(). The new method for getting free space always uses the filesystem's correct root path, so it works for internal, external or any other Android storage filesystem. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jasongin/cordova-plugin-file CB-7253 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-plugin-file/pull/145.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #145 ---- commit 4097a9855653aaf7f62806c06f1ae0502a29fbad Author: Jason Ginchereau Date: 2015-10-30T20:15:47Z CB-7253: requestFileSystem fails when no external storage is present There were 2 issues behind this bug: 1) DirectoryManager.getFreeDiskSpace() used an incorrect way of checking the free internal storage space: using a path of "/" would always result in 0 reported free space. 2) When checking whether requested space was available, the requestFileSystem() method would always check the external storage space and fallback to internal storage space, regardless of what type of filesystem (external, internal, or other) was being requested. To fix both of these issues, I've added a new getFreeSpaceInBytes() method on the FileSystem base class, which is called on the actual filesystem instance being retrieved by requestFileSystem(). The new method for getting free space always uses the filesystem's correct root path, so it works for internal, external or any other Android storage filesystem. ---- > window.requestFileSystem fails when no sd card is present and non-zero value is provided for size > ------------------------------------------------------------------------------------------------- > > Key: CB-7253 > URL: https://issues.apache.org/jira/browse/CB-7253 > Project: Apache Cordova > Issue Type: Bug > Components: Plugin File > Affects Versions: 3.5.0 > Environment: I discovered this issue on a Nexus7 emulator running android 4.4.2 with no sd card. > Reporter: Vincent Scuorzo > Assignee: Jason Ginchereau > Priority: Minor > Labels: easyfix > > The problem is that when no external storage is present the size parameter is compared to the available storage space on the internal file system which is incorrectly reported as 0. After reading a post on stack overflow (http://stackoverflow.com/questions/4799643/getting-all-the-total-and-available-space-on-android) I noticed that they were checking available space in a different way so I tried it and the issue went away. > You can see this bug in action by setting up an emulator as I described and running an app with the file plugin that can execute the following javascript: > window.requestFileSystem(PERSISTENT, 1024, function(fs){ console.log(fs); }, function(e){ console.log(e); }); > With the current release you will get an error related to reaching the storage quota since the available space is reported incorrectly. Change line 72 of src/android/DirectoryManager.java to read the following: > freeSpace = freeSpaceCalculation(Environment.getRootDirectory().getAbsolutePath()); > Run the same line of javascript as before and you will now have success, assuming you actually have the available space. > You can easily bypass this issue and access the filesystem by just passing 0 for the size but doing so will also circumvent the checks that ensure you don't try to use more space than is available. In my case, my app was handicapping itself because it thought it didn't have enough space to download additional resources when it should not have had any issues. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org