You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Colin Mahoney (JIRA)" <ji...@apache.org> on 2014/01/10 09:57:54 UTC

[jira] [Commented] (CB-5631) FileTransfer.download progress returns excatly twice as much loaded bytes on android

    [ https://issues.apache.org/jira/browse/CB-5631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13867633#comment-13867633 ] 

Colin Mahoney commented on CB-5631:
-----------------------------------

Submitted pull request:
https://github.com/apache/cordova-plugin-file-transfer/pull/14

Comment from commit:
*SimpleTrackingInputStream.getTotalRawBytesRead* returns twice the number of bytes actually read.

InputStream.read(byte[] buffer) calls InputStream.read(byte[] bytes, int offset, int count). As SimpleTrackingInputStream overrides both these methods a call to SimpleTrackingInputStream.read(byte[] buffer) results in a call to SimpleTrackingInputStream.read(byte[] bytes, int offset, int count) - and two calls to SimpleTrackingInputStream.updateBytesRead, so the counter bytesRead gets incremented twice for each read.

This change removes the implementation of SimpleTrackingInputStream.read(byte[] buffer).

> FileTransfer.download progress returns excatly twice as much loaded bytes on android
> ------------------------------------------------------------------------------------
>
>                 Key: CB-5631
>                 URL: https://issues.apache.org/jira/browse/CB-5631
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File Transfer
>    Affects Versions: 3.2.0
>            Reporter: Malte Legenhausen
>
> When I download a file under android and calculate the progress of the download the onprogress event.loaded variable is set to twice as much bytes as there where total available.
> I fixed the bug for me by simply dividing the result of getTotalRawBytesRead by 2.
> This bug occurs since cordova 3.0.0 only on Android. Tests on iOS return the right result. I downloaded a video file from an apache http server.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)