Correctly remove incomplete settings file

PR #17362.
This commit is contained in:
Chocobo1 2022-07-14 13:05:08 +08:00 committed by GitHub
parent d3e7e8a630
commit d2a29c2f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,10 +188,13 @@ bool SettingsStorage::writeNativeSettings() const
break;
}
if (nativeSettings->status() != QSettings::NoError)
return false;
const Path newPath {nativeSettings->fileName()};
if (nativeSettings->status() != QSettings::NoError)
{
Utils::Fs::removeFile(newPath);
return false;
}
QString finalPathStr = newPath.data();
const int index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
finalPathStr.remove(index, 4);