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

Add new save file handling #22

Merged
merged 22 commits into from
Jun 16, 2022
Merged

Add new save file handling #22

merged 22 commits into from
Jun 16, 2022

Conversation

liquidnya
Copy link

@liquidnya liquidnya commented Jun 8, 2022

This will fix issue #12.
This is a draft for introducing a new save file and better handling of saving such file.

The current changes as of now include using the library write-file-atomic to write one single save file for queue state and wait time. The old files are loaded and converted to the new file on startup if needed. The new file is also in the newly introduced directory data.
The library node-graceful-fs is also used for automatically retrying renaming of files, since that can fail sporadically under windows when the directory is locked, e.g. by virus scanner.
Documentation for the old and new file formats is available as comments in persistence.js.

The following things need to be done still before this can be merged:

  • Fix existing test cases
  • Create new test cases
    • Conversion of old data to new data
    • Fault tolerance tests
  • Use writeFileAtomicAsync for the customCodes.json file
  • Automatically delete version 1 save files after converting to a version 2 save file
  • Figure out if mixing writeFileAtomic and writeFileAtomicAsync is possible or just rewrite everything to use the async variant except for when the queue is loaded initially
    → keep writeFileAtomicSync for all uses for now
  • (Optional) Add a setting to use newlines and white spaces for the save file
  • (Optional) Rewrite the queue code that accesses wait time to use the object stored in the save file instead of using 2 lists
  • (Optional) Add the submission date of levels (Clear old entries of the queue #11)
  • (Optional) Add user ids to the wait list (!rename command and store user id #7)

Feedback to these changes are highly appreciated and there are open questions:

  • Should the customCodes.json file be moved into the data directory?
    → It is now stored in the ./data directory.
  • Should Store users last online time #21 be merged first, so that the last online time is already used in the new file format?
    → This has been merged into this PR.

@liquidnya
Copy link
Author

Adding a level will now add an initial wait time of 1.

@liquidnya liquidnya marked this pull request as ready for review June 12, 2022 14:27
@liquidnya liquidnya mentioned this pull request Jun 16, 2022
@liquidnya
Copy link
Author

This will fix #10 (additionally to #12).

@ToransuShoujo ToransuShoujo merged commit 5a49916 into ToransuShoujo:master Jun 16, 2022
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

Successfully merging this pull request may close these issues.

2 participants