Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5ADAE186AA for ; Wed, 9 Mar 2016 01:05:08 +0000 (UTC) Received: (qmail 10530 invoked by uid 500); 9 Mar 2016 01:05:08 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 10491 invoked by uid 500); 9 Mar 2016 01:05:08 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 10479 invoked by uid 99); 9 Mar 2016 01:05:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2016 01:05:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A2C1CDFA26; Wed, 9 Mar 2016 01:05:07 +0000 (UTC) From: riknoll To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-plugin-file pull request: CB-7862: FileReader reads large ... Content-Type: text/plain Message-Id: <20160309010507.A2C1CDFA26@git1-us-west.apache.org> Date: Wed, 9 Mar 2016 01:05:07 +0000 (UTC) Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55457515 --- Diff: www/FileReader.js --- @@ -96,6 +106,78 @@ function initRead(reader, file) { } /** + * Callback used by the following read* functions to handle incremental or final success. + * Must be bound to the FileReader's this along with all but the last parameter, + * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate) + * @param readType The name of the read function to call. + * @param encoding Text encoding, or null if this is not a text type read. + * @param offset Starting offset of the read. + * @param totalSize Total number of bytes or chars to read. + * @param accumulate A function that takes the callback result and accumulates it in this._result. + * @param r Callback result returned by the last read exec() call, or null to begin reading. + */ +function readSuccessCallback(readType, encoding, offset, totalSize, accumulate, r) { + if (this._readyState === FileReader.DONE) { + return; + } + + if (typeof r !== "undefined") { + accumulate(r); + this._progress = Math.min(this._progress + FileReader.READ_CHUNK_SIZE, totalSize); + + if (typeof this.onprogress === "function") { + this.onprogress(new ProgressEvent("progress", {loaded:this._progress, total:totalSize})); + } + } + + if (typeof r === "undefined" || this._progress < totalSize) { + var execArgs = [ + this._localURL, + offset + this._progress, + offset + this._progress + Math.min(totalSize - this._progress, FileReader.READ_CHUNK_SIZE)]; + if (encoding) { --- End diff -- Sure, that works. I just thought it was unclear why you were inserting an argument in this way --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org