1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 04:54:18 +00:00

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; break;
} }
if (nativeSettings->status() != QSettings::NoError)
return false;
const Path newPath {nativeSettings->fileName()}; const Path newPath {nativeSettings->fileName()};
if (nativeSettings->status() != QSettings::NoError)
{
Utils::Fs::removeFile(newPath);
return false;
}
QString finalPathStr = newPath.data(); QString finalPathStr = newPath.data();
const int index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive); const int index = finalPathStr.lastIndexOf(u"_new", -1, Qt::CaseInsensitive);
finalPathStr.remove(index, 4); finalPathStr.remove(index, 4);