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

fix: Add flush+fsync to write of config files #101

merged 1 commit into from
Jun 5, 2021


Copy link

@johan-bjareholt johan-bjareholt commented Jun 5, 2021

This is to lower the risk of corrupted config files

Hopefully this should reduce the risk of issues like ActivityWatch/activitywatch#502

The writes are still not completely safe though I think, to do that you would need to temporarily write the file to another file, flush+fsync and then move the file over the old one as renaming a file is atomic. At least that's how it works on Linux, assume it's the same on macOS/Linux.
But this was a quick fix and probably good enough.

This is to lower the risk of corrupted config files
Copy link

codecov bot commented Jun 5, 2021

Codecov Report

Merging #101 (03c62e3) into master (5864398) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #101      +/-   ##
+ Coverage   91.27%   91.28%   +0.01%     
  Files          33       33              
  Lines        1558     1560       +2     
  Branches      240      240              
+ Hits         1422     1424       +2     
  Misses        105      105              
  Partials       31       31              
Impacted Files Coverage Δ
aw_core/ 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5864398...03c62e3. Read the comment docs.

@johan-bjareholt johan-bjareholt merged commit 601ac7d into master Jun 5, 2021
@johan-bjareholt johan-bjareholt deleted the dev/config-fsync-fix branch June 5, 2021 11:54
Copy link

@johan-bjareholt Should we add this to the new toml configuration too maybe?

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

Successfully merging this pull request may close these issues.

None yet

2 participants