- BUGFIX: Remove old folder when moving a torrent

- BUGFIX: Improved reliability of torrent moving
This commit is contained in:
Christophe Dumez
2010-04-10 15:03:16 +00:00
parent 7953809024
commit f243b8535a
2 changed files with 12 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.2.6 * Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.2.6
- BUGFIX: Announce to all trackers at once - BUGFIX: Announce to all trackers at once
- BUGFIX: Added support for single-thread boost - BUGFIX: Added support for single-thread boost
- BUGFIX: Remove old folder when moving a torrent
- BUGFIX: Improved reliability of torrent moving
* Wed Apr 07 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.5 * Wed Apr 07 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.5
- BUGFIX: Fix crash when adding a new torrent label - BUGFIX: Fix crash when adding a new torrent label

View File

@@ -1652,12 +1652,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} else { } else {
new_save_path = old_dir.absoluteFilePath(new_label); new_save_path = old_dir.absoluteFilePath(new_label);
} }
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
if(move_storage) { if(move_storage) {
// Move storage // Move storage
h.move_storage(new_save_path); h.move_storage(new_save_path);
} }
emit savePathChanged(h);
} }
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) { void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
@@ -1669,12 +1667,10 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
const QDir old_dir(old_save_path); const QDir old_dir(old_save_path);
if(old_dir.dirName() != label) { if(old_dir.dirName() != label) {
const QString &new_save_path = old_dir.absoluteFilePath(label); const QString &new_save_path = old_dir.absoluteFilePath(label);
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
if(old_dir == QDir(h.save_path())) { if(old_dir == QDir(h.save_path())) {
// Move storage // Move storage
h.move_storage(new_save_path); h.move_storage(new_save_path);
} }
emit savePathChanged(h);
} }
} }
@@ -1965,8 +1961,17 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(a.get())) { else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if(h.is_valid()) if(h.is_valid()) {
// Attempt to remove old folder if empty
const QString& old_save_path = TorrentPersistentData::getSavePath(h.hash());
const QString new_save_path = QString(p->path.c_str());
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
qDebug("Attempting to remove %s", qPrintable(old_save_path));
QDir().rmpath(old_save_path);
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
emit savePathChanged(h);
h.force_recheck(); //XXX: Required by libtorrent for now h.force_recheck(); //XXX: Required by libtorrent for now
}
} }
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) { else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);