From issues-return-92965-archive-asf-public=cust-asf.ponee.io@cordova.apache.org Tue Feb 27 13:24:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C8936180651 for ; Tue, 27 Feb 2018 13:24:04 +0100 (CET) Received: (qmail 50261 invoked by uid 500); 27 Feb 2018 12:24:03 -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 50250 invoked by uid 99); 27 Feb 2018 12:24:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Feb 2018 12:24:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4E2131801AF for ; Tue, 27 Feb 2018 12:24:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id wyFu3cuMY-4E for ; Tue, 27 Feb 2018 12:24:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 09A435F3B5 for ; Tue, 27 Feb 2018 12:24:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 81B45E01DA for ; Tue, 27 Feb 2018 12:24:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 34C2624068 for ; Tue, 27 Feb 2018 12:24:00 +0000 (UTC) Date: Tue, 27 Feb 2018 12:24:00 +0000 (UTC) From: "Anthony Ward (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CB-13923) CordovaResourceApi.java method OpenForReadResult returns a -1 length MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Anthony Ward created CB-13923: --------------------------------- Summary: CordovaResourceApi.java method OpenForReadResult retu= rns a -1 length Key: CB-13923 URL: https://issues.apache.org/jira/browse/CB-13923 Project: Apache Cordova Issue Type: Bug Components: cordova-android Affects Versions: cordova-android-7.0.0 Environment: cordova 8.0.0 cordova-android 7.0.0 cordova-plugin-file 6.0.1 Reporter: Anthony Ward Assignee: Joe Bowser Here are details to recreate: [https://github.com/AnthonyWard/cordova-file-plugin-bug] In *cordova-android* the CordovaResourceApi.java -> OpenForReadResult metho= d returns a -1 length in certain circumstances. This has a knock on effect to the *cordova-plugin-file* > Filesystem.java= =C2=A0> readFileAtURL method, causing file corruption as each chunk effecti= vely has no end. There is a possible fix in the plugin cordova-plugin-file already proposed [https://github.com/apache/cordova-plugin-file/pull/217] https://issues.apache.org/jira/browse/CB-13245?jql=3Dtext%20~%20%22CordovaR= esourceApi%22 Or I propose it=C2=A0could be fixed upstream in cordova-android here: [https://github.com/apache/cordova-android/blob/master/framework/src/org/ap= ache/cordova/CordovaResourceApi.java] In the method OpenForReadResult there is one path (in the catch) that leave= s the length as -1 causing the defect try { assetFd =3D assetManager.openFd(assetPath); inputStream =3D assetFd.createInputStream(); length =3D assetFd.getLength()= ; } catch (FileNotFoundException e) { // Will occur if the file is compressed. inputStream =3D assetManager.open(assetPath); } Adding length =3D inputStream.available(); in the catch fixes the issue for= me, but I'm not a java developer so can't evaluate if that's a bad idea fo= r another reason. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org