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

Atomic Save for Setting #1763

Merged
merged 7 commits into from
Jan 22, 2023
Merged

Atomic Save for Setting #1763

merged 7 commits into from
Jan 22, 2023

Conversation

taooceros
Copy link
Member

@taooceros taooceros commented Jan 7, 2023

Atomic Save for Setting By

  1. Create a Temp File
  2. Write the new setting to the Temp File
  3. Call File.Replace to replace the Temp File to the Setting File and create a backup
  4. Delete the Temp File (Well If we want to can keep it there and use it as the second backup)

Interesting thing is: I also learn this strategy in my OS class.

Tested

  • Save Successfully create a backup file
  • If the original setting file is invalid, it will load the backup file

Should closes #641

Whether File.Replace is atomic is unclear to me due to discussion in https://stackoverflow.com/a/35128468/13906571. Though, if I understand the post correctly, it is safe to use if we always keep a backup, with the additional document in https://learn.microsoft.com/en-us/windows/win32/fileio/deprecation-of-txf?redirectedfrom=MSDN.

@github-actions

This comment has been minimized.

@taooceros taooceros requested a review from jjw24 January 7, 2023 19:17
@taooceros
Copy link
Member Author

taooceros commented Jan 7, 2023

@check-spelling-bot Report

🔴 Please review

See the 📂 files view or the 📜action log for details.

Unrecognized words (1)

bak
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

To have the bot do this for you, reply quoting the following line: @check-spelling-bot apply updates.
If the flagged items are 🤯 false positives

@check-spelling-bot apply updates.

@taooceros
Copy link
Member Author

Well I still don't understand how to let the bot apply the update🤣🤣

@taooceros
Copy link
Member Author

@check-spelling-bot Report

🔴 Please review

See the 📂 files view or the 📜action log for details.

Unrecognized words (1)

bak
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

To have the bot do this for you, reply quoting the following line: @check-spelling-bot apply updates.
If the flagged items are 🤯 false positives

@check-spelling-bot apply updates.

@github-actions

This comment has been minimized.

@VictoriousRaptor
Copy link
Contributor

Well I still don't understand how to let the bot apply the update🤣🤣

I disabled it in settings because the author says its experimental. You can edit spelling.yml to enable it.

@jjw24
Copy link
Member

jjw24 commented Jan 17, 2023

Well I still don't understand how to let the bot apply the update🤣🤣

I disabled it in settings because the author says its experimental. You can edit spelling.yml to enable it.

Ohh no wonder I wasnt able to as well 🤣🤣

@jjw24
Copy link
Member

jjw24 commented Jan 17, 2023

Well I still don't understand how to let the bot apply the update🤣🤣

I disabled it in settings because the author says its experimental. You can edit spelling.yml to enable it.

DW about it then since it's experimental.

@jjw24 jjw24 added the bug Something isn't working label Jan 17, 2023
@jjw24 jjw24 added this to the 1.11.1 milestone Jan 17, 2023
@jjw24
Copy link
Member

jjw24 commented Jan 17, 2023

@taooceros please resolve conflict

@jjw24 jjw24 modified the milestones: 1.11.1, 1.12.0 Jan 22, 2023
@jjw24 jjw24 enabled auto-merge January 22, 2023 22:14
@jjw24 jjw24 merged commit 3a3da51 into dev Jan 22, 2023
@jjw24 jjw24 deleted the atomic_setting_save branch January 22, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Settings Reset Automatically
3 participants