mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
fix import torrent with "Keep incomplete torrents in:" ticked
* also had to account for "Append the label of the torrent to the save path", but again, this was only an issue when "Keep incomplete torrents in:" is selected * A multi-file torrent with only one file (ie: a single file within a folder), was being treated as a single-file torrent, making it impossible to import. Multi-file torrent detection code was copied from libtorrent. The information is available in libtorrent (under torrent_info::m_multifile), however it's a private member and I chose to go with copying the code that determines it, rather than modifying a library qBittorrent depends on. Conflicts: src/torrentimportdlg.cpp
This commit is contained in:
parent
59379942ac
commit
ac3efb664a
3 changed files with 18 additions and 9 deletions
|
@ -1016,7 +1016,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool f
|
|||
}
|
||||
|
||||
// Add a torrent to the Bittorrent session
|
||||
QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
|
||||
QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed, bool imported) {
|
||||
QTorrentHandle h;
|
||||
Preferences* const pref = Preferences::instance();
|
||||
|
||||
|
@ -1134,9 +1134,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
|||
// Remember label
|
||||
TorrentTempData::setLabel(hash, savePath_label.second);
|
||||
} else {
|
||||
savePath = getSavePath(hash, fromScanDir, path);
|
||||
savePath = getSavePath(hash, fromScanDir, path, imported);
|
||||
}
|
||||
if (!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
||||
if (!imported && !defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
||||
qDebug("addTorrent::Temp folder is enabled.");
|
||||
QString torrent_tmp_path = defaultTempPath;
|
||||
p.save_path = fsutils::toNativePath(torrent_tmp_path).toUtf8().constData();
|
||||
|
@ -2776,14 +2776,14 @@ session_status QBtSession::getSessionStatus() const {
|
|||
return s->status();
|
||||
}
|
||||
|
||||
QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString filePath) {
|
||||
QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString filePath, bool imported) {
|
||||
QString savePath;
|
||||
if (TorrentTempData::hasTempData(hash)) {
|
||||
savePath = fsutils::fromNativePath(TorrentTempData::getSavePath(hash));
|
||||
if (savePath.isEmpty()) {
|
||||
savePath = defaultSavePath;
|
||||
}
|
||||
if (appendLabelToSavePath) {
|
||||
if (!imported && appendLabelToSavePath) {
|
||||
qDebug("appendLabelToSavePath is true");
|
||||
const QString label = TorrentTempData::getLabel(hash);
|
||||
if (!label.isEmpty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue