mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add random number to temp file names
Mitigates against multiple instances trying to write to the same tmp file at the same time.
This commit is contained in:
parent
bc524cd0e9
commit
0025e0fcfa
2 changed files with 4 additions and 2 deletions
|
|
@ -287,7 +287,8 @@ void srb2::save_ng_gamedata()
|
|||
|
||||
std::string gamedataname_s {gamedatafilename};
|
||||
fs::path savepath {fmt::format("{}/{}", srb2home, gamedataname_s)};
|
||||
fs::path tmpsavepath {fmt::format("{}/{}.tmp", srb2home, gamedataname_s)};
|
||||
int random_number = rand();
|
||||
fs::path tmpsavepath {fmt::format("{}/{}_{}.tmp", srb2home, gamedataname_s, random_number)};
|
||||
|
||||
json ngdata_json = ng;
|
||||
|
||||
|
|
|
|||
|
|
@ -316,7 +316,8 @@ void PR_SaveProfiles(void)
|
|||
std::vector<uint8_t> ubjson = json::to_ubjson(ng);
|
||||
|
||||
std::string realpath = fmt::format("{}/{}", srb2home, PROFILESFILE);
|
||||
std::string tmppath = fmt::format("{}.tmp", realpath);
|
||||
int random_number = rand();
|
||||
std::string tmppath = fmt::format("{}_{}.tmp", realpath, random_number);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue