1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-02-24 16:02:39 +03:00
Octobot/TeamOctolings.Octobot
Octol1ttle 4785d162a2
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™️ 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 <l1ttleofficial@outlook.com>
2025-02-03 16:58:57 +05:00
..
Attributes Apply official naming guidelines to Octobot (#306) 2024-05-16 20:34:26 +05:00
Commands /about: Replace repo link with website link (#328) 2024-08-24 15:50:32 +00:00
Data Apply new inspection fixes (#329) 2024-08-24 20:48:47 +05:00
Extensions Handle temporary files being present when loading guild data (#345) 2025-02-03 16:58:57 +05:00
Parsers Apply official naming guidelines to Octobot (#306) 2024-05-16 20:34:26 +05:00
Responders Apply new inspection fixes (#329) 2024-08-24 20:48:47 +05:00
Services Handle temporary files being present when loading guild data (#345) 2025-02-03 16:58:57 +05:00
BuildInfo.cs /about: Replace repo link with website link (#328) 2024-08-24 15:50:32 +00:00
ColorsList.cs Apply official naming guidelines to Octobot (#306) 2024-05-16 20:34:26 +05:00
Messages.Designer.cs /about: Replace repo link with website link (#328) 2024-08-24 15:50:32 +00:00
Messages.resx /about: Replace repo link with website link (#328) 2024-08-24 15:50:32 +00:00
Messages.ru.resx /about: Replace repo link with website link (#328) 2024-08-24 15:50:32 +00:00
Program.cs Apply official naming guidelines to Octobot (#306) 2024-05-16 20:34:26 +05:00
TeamOctolings.Octobot.csproj Bump TargetFramework from 8.0 to 9.0 (#344) 2024-12-01 19:52:47 +03:00
Utility.cs Always default cancellation tokens (#319) 2024-06-25 15:09:45 +05:00