cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-10960) Uncaught #<FileError> in write() when readyState != WRITING ?
Date Fri, 08 Apr 2016 06:14:26 GMT

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

ASF GitHub Bot commented on CB-10960:
-------------------------------------

Github user daserge commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file/pull/177#discussion_r58983833
  
    --- Diff: www/FileWriter.js ---
    @@ -107,8 +108,29 @@ FileWriter.prototype.write = function(data) {
             var fileReader = new FileReader();
             fileReader.onload = function() {
                 // Call this method again, with the arraybuffer as argument
    -            FileWriter.prototype.write.call(that, this.result);
    +            FileWriter.prototype.write.call(that, this.result, true /* isPendingBlobReadResult
*/);
             };
    +        fileReader.onerror = function (evt) {
    +            // DONE state
    +            that.readyState = FileWriter.DONE;
    +
    +            // Save error
    +            that.error = evt.target.error;
    --- End diff --
    
    Thanks, I will update it!


> Uncaught #<FileError> in write() when readyState != WRITING ?
> -------------------------------------------------------------
>
>                 Key: CB-10960
>                 URL: https://issues.apache.org/jira/browse/CB-10960
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 4.1.1
>         Environment: Android
>            Reporter: Samo Dadela
>              Labels: android
>         Attachments: code.js
>
>
> Excuse me if I did something stupid - I'm new to Cordova and JS.
> I thought that calling write() after checking readyState != WRITING would work. 
> {code}
> function writeQueue(c) {
>         while ( !(logWriter.readyState === FileWriter.WRITING) ) {
>             var msg = logQueue.dequeue();
>             if (!msg) {
>                 return;
>             }
>             var blob = new Blob([msg+c], { type: 'text/plain' });
>             logWriter.write(blob);
>         }
>     }
> }
> {code}
> But I get:
> 0     277161   log      log writer: cdvfile://localhost/files/bala.log
> 1     277199   log      log writer: onwriteend
> 2     283616   log      log writer: onwriteend
> 3     283629   log      log writer: onwriteend
> 4     283651   error    Uncaught #<FileError>, http://192.168.1.200:8100/plugins/cordova-plugin-file/www/FileWriter.js,
Line: 130
> Line 130 is:
> {code}
>     // Throw an exception if we are already writing a file
>     if (this.readyState === FileWriter.WRITING) {
>         throw new FileError(FileError.INVALID_STATE_ERR);
>     }
> {code}
> How can readyState change to WRITING ? 
> Note: Queue is pure Javascript (http://code.stephenmorley.org/javascript/queues/Queue.src.js)



--
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


Mime
View raw message