Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Fix Settings Corruption #184

Merged
merged 2 commits into from
Feb 10, 2016
Merged

Fix Settings Corruption #184

merged 2 commits into from
Feb 10, 2016

Conversation

tacticalchihuahua
Copy link
Contributor

This PR ensures that disk writes to the settings.json file are synchronous, preventing other writes from occurring in parallel which can lead to a corrupted settings file.

Should fix #183 and #181

@MrFancyMonocle - review/test/merge?

@GalumphingCallooh
Copy link
Contributor

Looks good,I'd maybe add some sync error handling:

try {
    fs.writeFileSync(this._path, JSON.stringify(this.toObject(), null, 2));
    callback();
  }
  catch(err) {
    callback(err)
  }

@tacticalchihuahua
Copy link
Contributor Author

Good call, added error handler and unit test.

FYI - I'm not calling callback within the try block because if the callback raised an error, it would misbehave by calling itself again with the error (in your example).

@littleskunk
Copy link
Contributor

autobin binaries (only available for team members)
last commit: 1b8165136acde32af5ba6b42eceb4832b9e2485c
driveshare_0.5.0.amd64.deb

@GalumphingCallooh
Copy link
Contributor

Indeed, good call, merging.

GalumphingCallooh pushed a commit that referenced this pull request Feb 10, 2016
@GalumphingCallooh GalumphingCallooh merged commit 0551a81 into storj-archived:develop Feb 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants