mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 05:44:25 +00:00
When removing torrents from hard disk, also remove root folders
This commit is contained in:
parent
9373796dd5
commit
f9684d662d
@ -771,10 +771,12 @@ void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
|
|||||||
}
|
}
|
||||||
const QString &fileName = h.name();
|
const QString &fileName = h.name();
|
||||||
// Remove it from session
|
// Remove it from session
|
||||||
if(delete_local_files)
|
if(delete_local_files) {
|
||||||
|
savePathsToRemove[hash] = h.save_path();
|
||||||
s->remove_torrent(h.get_torrent_handle(), session::delete_files);
|
s->remove_torrent(h.get_torrent_handle(), session::delete_files);
|
||||||
else
|
} else {
|
||||||
s->remove_torrent(h.get_torrent_handle());
|
s->remove_torrent(h.get_torrent_handle());
|
||||||
|
}
|
||||||
// Remove it from torrent backup directory
|
// Remove it from torrent backup directory
|
||||||
QDir torrentBackup(misc::BTBackupLocation());
|
QDir torrentBackup(misc::BTBackupLocation());
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
@ -2070,6 +2072,41 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (torrent_deleted_alert* p = dynamic_cast<torrent_deleted_alert*>(a.get())) {
|
||||||
|
qDebug("A torrent was deleted from the hard disk, attempting to remove the root folder too...");
|
||||||
|
QString hash;
|
||||||
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
|
hash = misc::toQString(p->info_hash);
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Unfortunately libtorrent v0.14 does not provide the hash,
|
||||||
|
// only the torrent handle that is often invalid when it arrives
|
||||||
|
try {
|
||||||
|
if(p->handle.is_valid()) {
|
||||||
|
hash = misc::toQString(p->handle.info_hash());
|
||||||
|
}
|
||||||
|
}catch(std::exception){}
|
||||||
|
#endif
|
||||||
|
if(!hash.isEmpty()) {
|
||||||
|
if(savePathsToRemove.contains(hash)) {
|
||||||
|
misc::removeEmptyTree(savePathsToRemove.take(hash));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// XXX: Fallback
|
||||||
|
QStringList hashes_deleted;
|
||||||
|
foreach(const QString& key, savePathsToRemove.keys()) {
|
||||||
|
// Attempt to delete
|
||||||
|
misc::removeEmptyTree(savePathsToRemove[key]);
|
||||||
|
if(!QDir(savePathsToRemove[key]).exists()) {
|
||||||
|
hashes_deleted << key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clean up
|
||||||
|
foreach(const QString& key, hashes_deleted) {
|
||||||
|
savePathsToRemove.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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()) {
|
||||||
|
@ -226,6 +226,7 @@ private:
|
|||||||
QPointer<BandwidthScheduler> bd_scheduler;
|
QPointer<BandwidthScheduler> bd_scheduler;
|
||||||
QMap<QUrl, QString> savepath_fromurl;
|
QMap<QUrl, QString> savepath_fromurl;
|
||||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||||
|
QHash<QString, QString> savePathsToRemove;
|
||||||
QStringList torrentsToPausedAfterChecking;
|
QStringList torrentsToPausedAfterChecking;
|
||||||
QTimer resumeDataTimer;
|
QTimer resumeDataTimer;
|
||||||
// Ratio
|
// Ratio
|
||||||
|
@ -3,7 +3,7 @@ LANG_PATH = lang
|
|||||||
ICONS_PATH = Icons
|
ICONS_PATH = Icons
|
||||||
|
|
||||||
# Set the following variable to 1 to enable debug
|
# Set the following variable to 1 to enable debug
|
||||||
DEBUG_MODE = 0
|
DEBUG_MODE = 1
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
Loading…
x
Reference in New Issue
Block a user