mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
Move the 'qBittorrent-resume' file even when no magnets were recovered. Also make sure to rename it with a unique name. Closes #4334.
This commit is contained in:
parent
17f1a7d22a
commit
c700b8c5c5
1 changed files with 14 additions and 4 deletions
|
@ -118,14 +118,15 @@ bool upgrade(bool ask = true)
|
||||||
QString oldResumeFilename = oldResumeSettings->fileName();
|
QString oldResumeFilename = oldResumeSettings->fileName();
|
||||||
QVariantHash oldResumeData = oldResumeSettings->value("torrents").toHash();
|
QVariantHash oldResumeData = oldResumeSettings->value("torrents").toHash();
|
||||||
delete oldResumeSettings;
|
delete oldResumeSettings;
|
||||||
if (oldResumeData.isEmpty())
|
bool oldResumeWasEmpty = oldResumeData.isEmpty();
|
||||||
|
if (oldResumeWasEmpty)
|
||||||
Utils::Fs::forceRemove(oldResumeFilename);
|
Utils::Fs::forceRemove(oldResumeFilename);
|
||||||
|
|
||||||
|
|
||||||
QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup");
|
QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup");
|
||||||
QDir backupFolderDir(backupFolderPath);
|
QDir backupFolderDir(backupFolderPath);
|
||||||
QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted);
|
QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted);
|
||||||
if (backupFiles.isEmpty() && oldResumeData.isEmpty()) return true;
|
if (backupFiles.isEmpty() && oldResumeWasEmpty) return true;
|
||||||
if (ask && !userAcceptsUpgrade()) return false;
|
if (ask && !userAcceptsUpgrade()) return false;
|
||||||
|
|
||||||
int maxPrio = 0;
|
int maxPrio = 0;
|
||||||
|
@ -168,8 +169,17 @@ bool upgrade(bool ask = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oldResumeData.isEmpty())
|
if (!oldResumeWasEmpty) {
|
||||||
QFile(oldResumeFilename).rename(oldResumeFilename + ".bak");
|
int counter = 0;
|
||||||
|
QString backupResumeFilename = oldResumeFilename + ".bak";
|
||||||
|
|
||||||
|
while (QFile::exists(backupResumeFilename)) {
|
||||||
|
++counter;
|
||||||
|
backupResumeFilename = oldResumeFilename + ".bak" + QString::number(counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile::rename(oldResumeFilename, backupResumeFilename);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue