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:
[x] Fix existing test cases
[x] Create new test cases
[x] Conversion of old data to new data
[x] Fault tolerance tests
[x] Use writeFileAtomicAsync for the customCodes.json file
[x] 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
[x] (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 (#11)
(Optional) Add user ids to the wait list (#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 #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.
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 inpersistence.js
.The following things need to be done still before this can be merged:
writeFileAtomicAsync
for thecustomCodes.json
fileFigure out if mixing→ keepwriteFileAtomic
andwriteFileAtomicAsync
is possible or just rewrite everything to use the async variant except for when the queue is loaded initiallywriteFileAtomicSync
for all uses for now(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 (#11)(Optional) Add user ids to the wait list (#7)Feedback to these changes are highly appreciated and there are open questions:
customCodes.json
file be moved into thedata
directory? → It is now stored in the./data
directory.