[
https://issues.apache.org/jira/browse/CB-14197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16537631#comment-16537631
]
ASF GitHub Bot commented on CB-14197:
-------------------------------------
wfairclough opened a new pull request #237: CB-14197: (all) Fix for
createFile/writeFile silently failing to send 'write' action
URL: https://github.com/apache/cordova-plugin-file/pull/237
FileWriter is missing the require('./FileReader') module causing the
native FileReader to be used instead of the FileReader proxy.
Oddly this does not happen everytime, but I could consistently
reproduce the issue when running subsequent `cordova run android`
commands on an Ionic app running in a 7.1.1 Android Emulator.
### Platforms affected
All Platforms
Witnessed on Android
### What does this PR do?
Adds a missing require statement to ensure the correct FileReader is used
### What testing has been done on this change?
Since this issue was very difficult to reproduce it was pretty hard to test.
We found
that this issue occurs most frequently when running our ionic app in the
Android
emulator and then run `ionic cordova run android` multiple times to
reinstall the app
before we consistently saw the issue. With the changes from this PR we
stopped
seeing the issue entirely.
I believe this PR will also fix the issue reported on the ionic-native
project:
https://github.com/ionic-team/ionic-native/issues/2067
`npm test` passes
### Checklist
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html)
in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform
affected.
- [ ] Added automated test coverage as appropriate for this change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> createFile/writeFile does not consistently execute the 'write' action
> resulting in files of size 0
> --------------------------------------------------------------------------------------------------
>
> Key: CB-14197
> URL: https://issues.apache.org/jira/browse/CB-14197
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-file
> Reporter: Will Fairclough
> Priority: Major
>
> Occasionally when calling the *createFile* API the *write* action does not
> get called. It was not very consistent though and it is very hard to
> reproduce. It seems as though the *onload* event was not firing on the
> fileReader in the write method resulting in the file never getting written
> and no callbacks being fired.
> {code:java}
> if (data instanceof File || (!isProxySupportBlobNatively && supportsBinary &&
> data instanceof Blob)) {
> var fileReader=new FileReader();
> /* eslint-enable no-undef */
> fileReader.onload=function () {
> // Call this method again, with the arraybuffer as argument
> FileWriter.prototype.write.call(that, this.result, true/*
> isPendingBlobReadResult */);
> };
> ...
> }
> {code}
> We found we would notice the issue more consistently when running the app in
> the Android emulator subsequent times in a row with the command:
> {code:java}
> $ cordova run android{code}
> We fixed this by requiring the FileReader module:
> [https://github.com/suitespot/cordova-plugin-file/commit/2a0da7f1a43e88b801ee70a3462c3df829f4c927]
> With this change we have not noticed the issue anymore.
> I also believe this *ionic-native* issue is related to this:
> [https://github.com/ionic-team/ionic-native/issues/2067#issuecomment-403600570]
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]