From 64654705ca5cfa32bc596aa7573e1fc91d2d1c4c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 22 Feb 2011 18:37:25 +0000 Subject: [PATCH] BUGFIX: Fix torrent upload from Web UI (Windows) --- Changelog | 3 ++- src/qtlibtorrent/qbtsession.cpp | 2 ++ src/webui/httpconnection.cpp | 14 +++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index 08f44c860..53fa21f95 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,8 @@ * Unreleased - Christophe Dumez - v2.6.7 - BUGFIX: Encoding fixes (Windows) - - BUGFIX: Fix "append label to save path" on Windows + - BUGFIX: Fix "append label to save path" (Windows) - BUGFIX: Disable OS cache for aligned files to reduce memory consumption + - BUGFIX: Fix torrent upload from Web UI (Windows) * Tue Feb 8 2011 - Christophe Dumez - v2.6.6 - FEATURE: IP address reported to trackers is now customizable diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 179445909..ccff9ffc9 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -825,6 +825,8 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) { qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath)); } + qDebug("Adding magnet URI: %s", qPrintable(magnet_uri)); + // Adding torrent to Bittorrent session try { h = QTorrentHandle(add_magnet_uri(*s, magnet_uri.toStdString(), p)); diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 8017e5af7..a5af92d6c 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -389,23 +389,27 @@ void HttpConnection::respondCommand(QString command) QByteArray torrentfile = parser.torrent(); // Get a unique filename QString filePath; - QTemporaryFile tmpfile; - tmpfile.setAutoRemove(false); - if (tmpfile.open()) { - filePath = tmpfile.fileName(); + QTemporaryFile *tmpfile = new QTemporaryFile; + tmpfile->setAutoRemove(false); + if (tmpfile->open()) { + filePath = tmpfile->fileName(); } else { std::cerr << "I/O Error: Could not create temporary file" << std::endl; return; } - tmpfile.close(); + tmpfile->close(); // Now temporary file is created but closed so that it can be used. // write torrent to temporary file QFile torrent(filePath); if(torrent.open(QIODevice::WriteOnly)) { torrent.write(torrentfile); torrent.close(); + } else { + std::cerr << "I/O Error: Could not create temporary file" << std::endl; + return; } emit torrentReadyToBeDownloaded(filePath, false, QString(), false); + delete tmpfile; // Prepare response generator.setStatusLine(200, "OK"); generator.setContentTypeByExt("html");