From a5f6663e6501ffa4c323bd44fe5d8b71b76eb988 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 19 Oct 2007 16:00:42 +0000 Subject: [PATCH] - BUGFIX: Fixed deletion of subfolders when deleting torrents from hard drive --- TODO | 1 + src/bittorrent.cpp | 21 +++++++++++++++------ src/bittorrent.h | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index dc0a3fbf4..071a4d2b9 100644 --- a/TODO +++ b/TODO @@ -62,4 +62,5 @@ rc5->rc6 changelog: - BUGFIX: configure doesn't require paths with a terminal "/" anymore - BUGFIX: Fixed minimize to tray feature - BUGFIX: Fixed folders progress calculation in torrent properties +- BUGFIX: Fixed deletion of subfolders when deleting torrents from hard drive - I18N: Fixed swedish, French, Spanish translations \ No newline at end of file diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index e0b7e2702..c7ea4b58f 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -27,6 +27,7 @@ #include "bittorrent.h" #include "misc.h" #include "downloadThread.h" +#include "deleteThread.h" #include #include @@ -61,6 +62,8 @@ bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false downloader = new downloadThread(this); connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); + // File deleter (thread) + deleter = new deleteThread(this); qDebug("* BTSession constructed"); } @@ -69,6 +72,7 @@ bittorrent::~bittorrent() { // Disable directory scanning disableDirectoryScanning(); // Delete our objects + delete deleter; delete timerAlerts; delete ETARefresher; delete downloader; @@ -206,13 +210,12 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { } QString savePath = h.save_path(); QString fileName = h.name(); - // Remove it from session - if(permanent) { - qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); - s->remove_torrent(h.get_torrent_handle(), session::delete_files); - } else { - s->remove_torrent(h.get_torrent_handle()); + arborescence *files_arb = 0; + if(permanent){ + files_arb = new arborescence(h.get_torrent_info()); } + // Remove it from session + s->remove_torrent(h.get_torrent_handle()); // Remove it from torrent backup directory QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QStringList filters; @@ -244,6 +247,12 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { std::cerr << "Error: Torrent " << hash.toStdString() << " is neither in finished or unfinished list\n"; } } + if(permanent && files_arb != 0) { + // Remove from Hard drive + qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); + // Deleting in a thread to avoid GUI freeze + deleter->deleteTorrent(savePath, files_arb); + } } // Return a list of hashes for the finished torrents diff --git a/src/bittorrent.h b/src/bittorrent.h index 817b7fcab..383f3a238 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -33,6 +33,7 @@ using namespace libtorrent; class downloadThread; +class deleteThread; class QTimer; class bittorrent : public QObject{ @@ -53,6 +54,7 @@ class bittorrent : public QObject{ QHash > ratioData; QTimer *ETARefresher; QHash > > trackersErrors; + deleteThread *deleter; QStringList waitingForPause; QStringList finishedTorrents; QStringList unfinishedTorrents;