-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File.writeFile's options has 'replace' and 'append' inverted, breaking the function #789
Comments
Prior to this patch, `File.writeFile` has the `replace` and `append` options flipped; setting `replace: true` would block the file from being replaced, and setting `append: true` would always create a new file and never append.
There was a recent patch that was not included in your fork so I think you didn't see it yet. The current code is as follows:
I'm not sure what is a better option to use, As for the exclusive option, you're right. I can see here https://github.com/apache/cordova-plugin-file/blob/master/src/android/LocalFilesystem.java#L140-L145 if the file exists and we have both |
I actually did see that code, but it's broken, for a number of reasons. First, with the current code, Second, I think Third, and my pull request was guilty of this too (I didn't want to make unnecessary changes but rather fix what was there), I think that Every other file IO library I've seen deals with this the same way: the default mode of operation when writing a file is to create a new file if there wasn't one, or if there was, replace it and overwrite. Supporting |
Yeah that makes sense. Just pushed a commit to fix this. |
Here,
ionic-native
setsexclusive = options.replace
: https://github.com/driftyco/ionic-native/blob/master/src/plugins/file.ts#L682And here, the Cordova plugin rejects an existing file if
exclusive
is set: https://github.com/apache/cordova-plugin-file/blob/master/src/android/LocalFilesystem.java#L119ionic-native
has its options flipped, should beexclusive = !options.replace
.Another error - the 'append' feature is broken: https://github.com/driftyco/ionic-native/blob/master/src/plugins/file.ts#L681 should have
create: !options.append
.Other methods in this file seem to support the replace flag appropriately.
The text was updated successfully, but these errors were encountered: