Windows specific: Transactional saving of PrusaSlicer.ini to ensure

that configuration could be recovered in the case PrusaSlicer.ini
is corrupted during saving. The config is first written into a temp file
marked with a MD5 checksum. Once the file is saved, it is
copied to a backup file first, then moved to PrusaSlicer.ini.

When loading PrusaSlicer.ini fails, the backup file will be loaded
instead, however only if its MD5 checksum is valid.

The following "Fixes" comments are for github triggers. We implemented
a workaround, not a fix, we don't actually know how the data corruption
happens and why. Most likely the "Move file" Windows API is not atomic
and if PrusaSlicer crashes on another thread while moving the file,
PrusaSlicer.ini will only be partially saved, with the rest of the file
filled with nulls. We did not "fix" the issue, we just hope that our
workaround will help in majority of cases.

Fixes prusaslicer wont open 2.3 windows 10 #5812
Fixes Won't Open - Windows 10 #4915
Fixes PrusaSlicer Crashes upon opening with "'=' character not found in
line error" #2438
Fixes Fails to open on blank slic3r.ini %user%\AppData\Roaming\Slic3rPE
This commit is contained in:
Vojtech Bubnik 2021-06-25 16:44:06 +02:00
parent 1378d2084a
commit 9b70efc46a
2 changed files with 143 additions and 26 deletions

View file

@ -37,7 +37,7 @@ public:
// Load the slic3r.ini from a user profile directory (or a datadir, if configured).
// return error string or empty strinf
std::string load();
std::string load();
// Store the slic3r.ini into a user profile directory (or a datadir, if configured).
void save();