mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-26 09:48:19 +03:00
Make settings file recovery more robust
We should not blindly remove the leftover settings file, as the following write() operation could fail and the user would lost all settings. We should try renaming it instead.
This commit is contained in:
parent
7d9c282db9
commit
0ede11a1b7
1 changed files with 6 additions and 2 deletions
|
@ -241,8 +241,12 @@ QVariantHash TransactionalSettings::read()
|
||||||
.arg(Utils::Fs::toNativePath(newPath))
|
.arg(Utils::Fs::toNativePath(newPath))
|
||||||
, Log::WARNING);
|
, Log::WARNING);
|
||||||
|
|
||||||
Utils::Fs::forceRemove(newPath);
|
QString finalPath = newPath;
|
||||||
write(res);
|
int index = finalPath.lastIndexOf("_new", -1, Qt::CaseInsensitive);
|
||||||
|
finalPath.remove(index, 4);
|
||||||
|
|
||||||
|
Utils::Fs::forceRemove(finalPath);
|
||||||
|
QFile::rename(newPath, finalPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deserialize(m_name, res);
|
deserialize(m_name, res);
|
||||||
|
|
Loading…
Reference in a new issue