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();
|
bool hasProject = !crashFileData.value("project", "").empty();
|
||||||
|
|
||||||
auto backupFilePath = path / BackupFileName;
|
auto backupFilePath = path / BackupFileName;
|
||||||
|
auto backupFilePathOld = path / BackupFileName;
|
||||||
|
backupFilePathOld.replace_extension(".hexproj.old");
|
||||||
|
|
||||||
bool hasBackupFile = wolv::io::fs::exists(backupFilePath);
|
bool hasBackupFile = wolv::io::fs::exists(backupFilePath);
|
||||||
|
|
||||||
if (!hasProject && !hasBackupFile) {
|
if (!hasProject && !hasBackupFile) {
|
||||||
log::warn("No project file or backup file found in crash.json file");
|
log::warn("No project file or backup file found in crash.json file");
|
||||||
|
|
||||||
crashFile.close();
|
crashFile.close();
|
||||||
|
|
||||||
|
// Delete crash.json file
|
||||||
wolv::io::fs::remove(crashFilePath);
|
wolv::io::fs::remove(crashFilePath);
|
||||||
|
|
||||||
|
// 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);
|
wolv::io::fs::remove(backupFilePath);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue