mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-05 22:57:25 +03:00
Merge pull request #6140 from Chocobo1/relocateNoRemove
After files relocate, don't remove the old folder even if it is empty
This commit is contained in:
commit
fed325a54d
2 changed files with 12 additions and 20 deletions
|
@ -1286,7 +1286,7 @@ void TorrentHandle::moveStorage(const QString &newPath)
|
||||||
m_queuedPath = newPath;
|
m_queuedPath = newPath;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QString oldPath = nativeActualSavePath();
|
const QString oldPath = nativeActualSavePath();
|
||||||
if (QDir(oldPath) == QDir(newPath)) return;
|
if (QDir(oldPath) == QDir(newPath)) return;
|
||||||
|
|
||||||
qDebug("move storage: %s to %s", qPrintable(oldPath), qPrintable(newPath));
|
qDebug("move storage: %s to %s", qPrintable(oldPath), qPrintable(newPath));
|
||||||
|
@ -1353,7 +1353,7 @@ void TorrentHandle::handleStorageMovedAlert(libtorrent::storage_moved_alert *p)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString newPath = Utils::String::fromStdString(p->path);
|
const QString newPath = Utils::String::fromStdString(p->path);
|
||||||
if (newPath != m_newPath) {
|
if (newPath != m_newPath) {
|
||||||
qWarning() << Q_FUNC_INFO << ": New path doesn't match a path in a queue.";
|
qWarning() << Q_FUNC_INFO << ": New path doesn't match a path in a queue.";
|
||||||
return;
|
return;
|
||||||
|
@ -1373,13 +1373,6 @@ void TorrentHandle::handleStorageMovedAlert(libtorrent::storage_moved_alert *p)
|
||||||
m_session->handleTorrentSavePathChanged(this);
|
m_session->handleTorrentSavePathChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to remove old folder if empty
|
|
||||||
QDir oldSaveDir(Utils::Fs::fromNativePath(m_oldPath));
|
|
||||||
if (oldSaveDir != QDir(m_session->defaultSavePath())) {
|
|
||||||
qDebug("Attempting to remove %s", qPrintable(m_oldPath));
|
|
||||||
QDir().rmpath(m_oldPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty())
|
while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty())
|
||||||
m_moveFinishedTriggers.takeFirst()();
|
m_moveFinishedTriggers.takeFirst()();
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,18 +249,17 @@ void TransferListWidget::setSelectedTorrentsLocation()
|
||||||
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
|
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
|
||||||
if (torrents.isEmpty()) return;
|
if (torrents.isEmpty()) return;
|
||||||
|
|
||||||
QString dir;
|
const QString oldLocation = torrents[0]->savePath();
|
||||||
const QDir saveDir(torrents[0]->savePath());
|
qDebug("Old location is %s", qPrintable(oldLocation));
|
||||||
qDebug("Old save path is %s", qPrintable(saveDir.absolutePath()));
|
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath(),
|
const QString newLocation = QFileDialog::getExistingDirectory(this, tr("Choose save path"), oldLocation,
|
||||||
QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails);
|
QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails);
|
||||||
if (!dir.isNull()) {
|
if (!QDir(newLocation).exists()) return;
|
||||||
qDebug("New path is %s", qPrintable(dir));
|
qDebug("New location is %s", qPrintable(newLocation));
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents) {
|
|
||||||
// Actually move storage
|
// Actually move storage
|
||||||
torrent->move(Utils::Fs::expandPathAbs(dir));
|
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||||
}
|
torrent->move(Utils::Fs::expandPathAbs(newLocation));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::pauseAllTorrents()
|
void TransferListWidget::pauseAllTorrents()
|
||||||
|
|
Loading…
Reference in a new issue