From 529ab304b47db182f7e7dd5808d43223c85b8c39 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 10 Apr 2010 15:00:35 +0000 Subject: [PATCH] Remove old folder when moving a torrent --- src/bittorrent.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 74ca2e424..fbb12d4df 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1950,7 +1950,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { else if (storage_moved_alert* p = dynamic_cast(a.get())) { QTorrentHandle h(p->handle); if(h.is_valid()) { - TorrentPersistentData::saveSavePath(h.hash(), QString(p->path.c_str())); + // 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 }