Browse Source

Remove old folder when moving a torrent

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
529ab304b4
  1. 8
      src/bittorrent.cpp

8
src/bittorrent.cpp

@ -1950,7 +1950,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -1950,7 +1950,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(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
}

Loading…
Cancel
Save