mirror of https://github.com/WerWolv/ImHex.git
impr: Keep a safety backup of the last crash backup around
This commit is contained in:
parent
bfdb9b4019
commit
bba4cf9578
|
@ -552,14 +552,26 @@ namespace hex::plugin::builtin {
|
|||
bool hasProject = !crashFileData.value("project", "").empty();
|
||||
|
||||
auto backupFilePath = path / BackupFileName;
|
||||
auto backupFilePathOld = path / BackupFileName;
|
||||
backupFilePathOld.replace_extension(".hexproj.old");
|
||||
|
||||
bool hasBackupFile = wolv::io::fs::exists(backupFilePath);
|
||||
|
||||
if (!hasProject && !hasBackupFile) {
|
||||
log::warn("No project file or backup file found in crash.json file");
|
||||
|
||||
crashFile.close();
|
||||
|
||||
// Delete crash.json file
|
||||
wolv::io::fs::remove(crashFilePath);
|
||||
wolv::io::fs::remove(backupFilePath);
|
||||
|
||||
// Delete old backup file
|
||||
wolv::io::fs::remove(backupFilePathOld);
|
||||
|
||||
// Try to move current backup file to the old backup location
|
||||
if (wolv::io::fs::copyFile(backupFilePath, backupFilePathOld)) {
|
||||
wolv::io::fs::remove(backupFilePath);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue