-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle temporary files being present when loading guild data (#345)
This PR fixes catastrophic guild data loading errors that appear when there are lingering temporary files. In normal operation, temporary files are deleted as soon as they are copied to the main file. It is also expected that temporary files are valid JSON files. However, due to a yesterday's DoS attack, something:tm: happened and a bunch of empty temporary files got written to disk. When Octobot recovered from the attack, it was unable to load any guild data because of the temporary files. This PR addresses this issue by changing the data loading logic: 1) Check if there's a temporary file. If it exists, try loading it. 2) If it is successfully loaded, move the temp file to the main file and resume operation as normal 3) If it could not be loaded, try loading the main file 4) If it is successfully loaded, delete the temporary file and resume operation as normal 5) If it is not, throw an error (like before) This PR was tested on production data and managed to load every guild without errors. Signed-off-by: Octol1ttle <[email protected]>
- Loading branch information
1 parent
bf81840
commit 4785d16
Showing
2 changed files
with
139 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters