Skip to content
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

concurrent writes and file corruption on iOS #31

Open
DjulLau opened this issue Oct 5, 2017 · 0 comments
Open

concurrent writes and file corruption on iOS #31

DjulLau opened this issue Oct 5, 2017 · 0 comments

Comments

@DjulLau
Copy link

DjulLau commented Oct 5, 2017

Hi,

Not sure if this is related to this particular module (maybe a lower level problem) but I'm experiencing file corruption on iOS.

I'm using fs.write() to replace the whole content of a file as a way to save data.
The function maybe called several times in a short period and no particular "waiting for previous write" mechanism has been implemented.
This is working perfectly well on Android but on iOS I sometime get a corrupted file with the whole content plus part off the content after, like if a write appended part of the data instead of replacing it.
Of course this ends in data corruption as the JSON content cannot be parsed anymore :(
I've tried to fs.remove() the file before fs.write() but fs.remove() sometimes fails (with Error code 1 even if mustExists is false)...

Questions:

  • Is it safe to call several fs.write() on the same file ?
  • If not what can I do the work around this problem ?

Thanks a lot,

Julien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant