mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
Fix TorrentHandle rootPath() and contentPath() methods
This commit is contained in:
parent
d413bc65ef
commit
6d7d566cdf
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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*| <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…
x
Reference in New Issue
Block a user