From f26fcabde1cbcdbdda6c8d15ed08fd41f3f5d702 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 17 Oct 2010 08:48:32 +0000 Subject: [PATCH] BUGFIX: Fix "torrent seeding after creation" feature --- Changelog | 3 +++ src/createtorrent_imp.cpp | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index a8f50a66d..236c94654 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Unreleased - Christophe Dumez - v2.4.6 + - BUGFIX: Fix "torrent seeding after creation" feature + * Tue Oct 12 2010 - Christophe Dumez - v2.4.5 - BUGFIX: Remember torrent completion date correctly - BUGFIX: Fix feature to keep incomplete torrents in a separate folder diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 4ed290632..1c094ddf3 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -220,16 +220,22 @@ void createtorrent::handleCreationSuccess(QString path, QString branch_path) { // Remove busy cursor setCursor(QCursor(Qt::ArrowCursor)); if(checkStartSeeding->isChecked()) { + QString root_folder; // Create save path temp data boost::intrusive_ptr t; try { t = new torrent_info(path.toUtf8().data()); + root_folder = misc::truncateRootFolder(t); } catch(std::exception&) { QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list.")); return; } QString hash = misc::toQString(t->info_hash()); - TorrentTempData::setSavePath(hash, branch_path); + QString save_path = branch_path; + if(!root_folder.isEmpty()) { + save_path = QDir(save_path).absoluteFilePath(root_folder); + } + TorrentTempData::setSavePath(hash, save_path); #if LIBTORRENT_VERSION_MINOR > 14 // Enable seeding mode (do not recheck the files) TorrentTempData::setSeedingMode(hash, true); @@ -285,8 +291,7 @@ void torrentCreatorThread::run() { char const* creator_str = "qBittorrent "VERSION; try { file_storage fs; - file_pool fp; - path full_path = complete(path(input_path.toLocal8Bit().data())); + path full_path = complete(path(input_path.toUtf8().constData())); // Adding files to the torrent add_files(fs, full_path, file_filter); if(abort) return; @@ -311,7 +316,7 @@ void torrentCreatorThread::run() { t.set_priv(is_private); if(abort) return; // create the torrent and print it to out - ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary); + ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary); bencode(std::ostream_iterator(out), t.generate()); emit updateProgress(100); emit creationSuccess(save_path, QString::fromUtf8(full_path.branch_path().string().c_str()));