mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 17:26:21 +03:00
When removing torrents from hard disk, also remove root folders
This commit is contained in:
parent
9373796dd5
commit
f9684d662d
3 changed files with 41 additions and 3 deletions
|
@ -771,10 +771,12 @@ void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
|
|||
}
|
||||
const QString &fileName = h.name();
|
||||
// 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);
|
||||
else
|
||||
} else {
|
||||
s->remove_torrent(h.get_torrent_handle());
|
||||
}
|
||||
// Remove it from torrent backup directory
|
||||
QDir torrentBackup(misc::BTBackupLocation());
|
||||
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())) {
|
||||
QTorrentHandle h(p->handle);
|
||||
if(h.is_valid()) {
|
||||
|
|
|
@ -226,6 +226,7 @@ private:
|
|||
QPointer<BandwidthScheduler> bd_scheduler;
|
||||
QMap<QUrl, QString> savepath_fromurl;
|
||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||
QHash<QString, QString> savePathsToRemove;
|
||||
QStringList torrentsToPausedAfterChecking;
|
||||
QTimer resumeDataTimer;
|
||||
// Ratio
|
||||
|
|
|
@ -3,7 +3,7 @@ LANG_PATH = lang
|
|||
ICONS_PATH = Icons
|
||||
|
||||
# Set the following variable to 1 to enable debug
|
||||
DEBUG_MODE = 0
|
||||
DEBUG_MODE = 1
|
||||
|
||||
# Global
|
||||
TEMPLATE = app
|
||||
|
|
Loading…
Reference in a new issue