Browse Source

Fix TorrentHandle rootPath() and contentPath() methods

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
6d7d566cdf
  1. 4
      src/base/bittorrent/session.cpp
  2. 7
      src/base/bittorrent/torrenthandle.cpp
  3. 4
      src/base/bittorrent/torrenthandle.h

4
src/base/bittorrent/session.cpp

@ -1405,7 +1405,9 @@ bool Session::deleteTorrent(const QString &hash, bool deleteLocalFiles) @@ -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 {

7
src/base/bittorrent/torrenthandle.cpp

@ -312,6 +312,9 @@ QString TorrentHandle::savePath(bool actual) const @@ -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 @@ -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

4
src/base/bittorrent/torrenthandle.h

@ -207,6 +207,9 @@ namespace BitTorrent @@ -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 @@ -223,6 +226,7 @@ namespace BitTorrent
// | | rootPath | contentPath |
// |---|------------------------------|--------------------------------------------|
// | A | /home/user/torrents/torrentA | /home/user/torrents/torrentA |
// | A*| <empty> | /home/user/torrents |
// | B | /home/user/torrents/torrentB | /home/user/torrents/torrentB/subdir1/file1 |
// | C | /home/user/torrents/file1 | /home/user/torrents/file1 |

Loading…
Cancel
Save