diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index ea6e8cf15..47972500c 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1405,7 +1405,9 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles) // Remove it from session if (deleteLocalFiles) { - m_savePathsToRemove[torrent->hash()] = torrent->rootPath(true); + QString rootPath = torrent->rootPath(true); + if (!rootPath.isEmpty()) + m_savePathsToRemove[torrent->hash()] = rootPath; m_nativeSession->remove_torrent(torrent->nativeHandle(), libt::session::delete_files); } else { diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 05788a8db..41f3fbf4a 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -312,6 +312,9 @@ QString TorrentHandle::savePath(bool actual) const QString TorrentHandle::rootPath(bool actual) const { + if ((filesCount() > 1) && !hasRootFolder()) + return QString(); + QString firstFilePath = filePath(0); const int slashIndex = firstFilePath.indexOf("/"); if (slashIndex >= 0) @@ -324,8 +327,10 @@ QString TorrentHandle::contentPath(bool actual) const { if (filesCount() == 1) return QDir(savePath(actual)).absoluteFilePath(filePath(0)); - else + else if (hasRootFolder()) return rootPath(actual); + else + return savePath(actual); } bool TorrentHandle::isAutoTMMEnabled() const diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrenthandle.h index 4d1360f61..f8226bcb1 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrenthandle.h @@ -207,6 +207,9 @@ namespace BitTorrent // file4 // // + // Torrent A* (Torrent A in "strip root folder" mode) + // + // // Torrent B (singlefile) // // torrentB/ @@ -223,6 +226,7 @@ namespace BitTorrent // | | rootPath | contentPath | // |---|------------------------------|--------------------------------------------| // | A | /home/user/torrents/torrentA | /home/user/torrents/torrentA | + // | A*| | /home/user/torrents | // | B | /home/user/torrents/torrentB | /home/user/torrents/torrentB/subdir1/file1 | // | C | /home/user/torrents/file1 | /home/user/torrents/file1 |