mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Setting for creating subfolder on multifile torrents. Closes #588.
This commit is contained in:
committed by
Vladimir Golovnev (Glassez)
parent
07af8c9648
commit
4b2d8a7941
@@ -1652,6 +1652,11 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
|
||||
p = magnetUri.addTorrentParams();
|
||||
}
|
||||
else if (torrentInfo.isValid()) {
|
||||
if (!addData.resumed && !addData.createSubfolder && torrentInfo.filesCount() > 1) {
|
||||
libtorrent::file_storage files = torrentInfo.files();
|
||||
files.set_name("");
|
||||
torrentInfo.remapFiles(files);
|
||||
}
|
||||
// Metadata
|
||||
if (!addData.resumed && !addData.hasSeedStatus)
|
||||
findIncompleteFiles(torrentInfo, savePath);
|
||||
|
||||
@@ -147,6 +147,7 @@ namespace BitTorrent
|
||||
QVector<int> filePriorities; // used if TorrentInfo is set
|
||||
bool ignoreShareRatio = false;
|
||||
bool skipChecking = false;
|
||||
bool createSubfolder = true;
|
||||
};
|
||||
|
||||
struct TorrentStatusReport
|
||||
|
||||
@@ -152,6 +152,7 @@ TorrentState::operator int() const
|
||||
return m_value;
|
||||
}
|
||||
|
||||
, createSubfolder(in.createSubfolder)
|
||||
// TorrentHandle
|
||||
|
||||
const qreal TorrentHandle::USE_GLOBAL_RATIO = -2.;
|
||||
@@ -230,6 +231,9 @@ QString TorrentHandle::name() const
|
||||
if (name.isEmpty())
|
||||
name = QString::fromStdString(m_nativeStatus.name);
|
||||
|
||||
if (name.isEmpty())
|
||||
name = QString::fromStdString(m_torrentInfo.origFiles().name());
|
||||
|
||||
if (name.isEmpty())
|
||||
name = m_hash;
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace BitTorrent
|
||||
bool sequential;
|
||||
bool hasSeedStatus;
|
||||
bool skipChecking;
|
||||
bool createSubfolder;
|
||||
TriStateBool addForced;
|
||||
TriStateBool addPaused;
|
||||
// for new torrents
|
||||
|
||||
@@ -276,6 +276,18 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const
|
||||
static_cast<int>((firstOffset + fileSize - 1) / pieceLength()));
|
||||
}
|
||||
|
||||
libtorrent::file_storage TorrentInfo::files() const
|
||||
{
|
||||
if (!isValid()) return libtorrent::file_storage();
|
||||
return m_nativeInfo->files();
|
||||
}
|
||||
|
||||
libtorrent::file_storage TorrentInfo::origFiles() const
|
||||
{
|
||||
if (!isValid()) return libtorrent::file_storage();
|
||||
return m_nativeInfo->orig_files();
|
||||
}
|
||||
|
||||
void TorrentInfo::renameFile(uint index, const QString &newPath)
|
||||
{
|
||||
if (!isValid()) return;
|
||||
@@ -293,6 +305,12 @@ int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TorrentInfo::remapFiles(libtorrent::file_storage const &fileStorage)
|
||||
{
|
||||
if (!isValid()) return;
|
||||
m_nativeInfo->remap_files(fileStorage);
|
||||
}
|
||||
|
||||
TorrentInfo::NativePtr TorrentInfo::nativeInfo() const
|
||||
{
|
||||
return m_nativeInfo;
|
||||
|
||||
@@ -98,8 +98,12 @@ namespace BitTorrent
|
||||
PieceRange filePieces(const QString &file) const;
|
||||
PieceRange filePieces(int fileIndex) const;
|
||||
|
||||
libtorrent::file_storage files() const;
|
||||
libtorrent::file_storage origFiles() const;
|
||||
|
||||
void renameFile(uint index, const QString &newPath);
|
||||
|
||||
void remapFiles(libtorrent::file_storage const &fileStorage);
|
||||
NativePtr nativeInfo() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -263,6 +263,16 @@ void Preferences::setLastLocationPath(const QString &path)
|
||||
setValue("Preferences/Downloads/LastLocationPath", Utils::Fs::fromNativePath(path));
|
||||
}
|
||||
|
||||
bool Preferences::getTorrentCreateSubfolder() const
|
||||
{
|
||||
return value("Preferences/Downloads/CreateSubfolder", true).toBool();
|
||||
}
|
||||
|
||||
void Preferences::setTorrentCreateSubfolder(bool b)
|
||||
{
|
||||
setValue("Preferences/Downloads/CreateSubfolder", b);
|
||||
}
|
||||
|
||||
QVariantHash Preferences::getScanDirs() const
|
||||
{
|
||||
return value("Preferences/Downloads/ScanDirsV2").toHash();
|
||||
|
||||
@@ -138,6 +138,8 @@ public:
|
||||
void setLastLocationPath(const QString &path);
|
||||
QVariantHash getScanDirs() const;
|
||||
void setScanDirs(const QVariantHash &dirs);
|
||||
bool getTorrentCreateSubfolder() const;
|
||||
void setTorrentCreateSubfolder(bool b);
|
||||
QString getScanDirsLastPath() const;
|
||||
void setScanDirsLastPath(const QString &path);
|
||||
bool isMailNotificationEnabled() const;
|
||||
|
||||
Reference in New Issue
Block a user