Author: sls Date: Tue Nov 11 00:25:32 2008 GMT Module: SOURCES Tag: HEAD ---- Log message: - use libtorrent-rasterbar-0.14 (changset 2070, exprimental)
---- Files affected: SOURCES: qbittorrent-libtorrent14.patch (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: SOURCES/qbittorrent-libtorrent14.patch diff -u /dev/null SOURCES/qbittorrent-libtorrent14.patch:1.1 --- /dev/null Tue Nov 11 01:25:33 2008 +++ SOURCES/qbittorrent-libtorrent14.patch Tue Nov 11 01:25:27 2008 @@ -0,0 +1,1274 @@ +Index: src/qtorrenthandle.h +=================================================================== +--- src/qtorrenthandle.h (revision 2069) ++++ src/qtorrenthandle.h (revision 2070) +@@ -54,7 +54,7 @@ + QString hash() const; + QString name() const; + float progress() const; +- const std::vector<bool>* pieces() const; ++ bitfield pieces() const; + void get_download_queue(std::vector<partial_piece_info>& queue) const; + QString current_tracker() const; + bool is_valid() const; +@@ -76,7 +76,7 @@ + int upload_limit() const; + int num_files() const; + bool has_metadata() const; +- entry write_resume_data() const; ++ void save_resume_data() const; + QString file_at(unsigned int index) const; + size_type filesize_at(unsigned int index) const; + std::vector<announce_entry> const& trackers() const; +@@ -84,7 +84,7 @@ + QString creator() const; + QString comment() const; + size_type total_failed_bytes() const; +- void file_progress(std::vector<float>& fp); ++ void file_progress(std::vector<size_type>& fp); + size_type total_payload_download(); + size_type total_payload_upload(); + QStringList files_path() const; +@@ -107,7 +107,7 @@ + void set_ratio(float ratio) const; + void replace_trackers(std::vector<announce_entry> const&) const; + void force_reannounce(); +- void set_sequenced_download_threshold(int val); ++ void set_sequential_download(bool); + void set_tracker_login(QString username, QString password); + + // +Index: src/arborescence.h +=================================================================== +--- src/arborescence.h (revision 2069) ++++ src/arborescence.h (revision 2070) +@@ -172,27 +172,27 @@ + torrent_file *root; + + public: +- arborescence(torrent_info t) { +- torrent_info::file_iterator fi = t.begin_files(); +- if(t.num_files() > 1) { +- root = new torrent_file(0, misc::toQString(t.name()), true); ++ arborescence(boost::intrusive_ptr<torrent_info> t) { ++ torrent_info::file_iterator fi = t->begin_files(); ++ if(t->num_files() > 1) { ++ root = new torrent_file(0, misc::toQString(t->name()), true); + } else { + // XXX: Will crash if there is no file in torrent +- root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0); ++ root = new torrent_file(0, misc::toQString(t->name()), false, fi->size, 0); + return; + } + int i = 0; +- while(fi != t.end_files()) { ++ while(fi != t->end_files()) { + QString path = QDir::cleanPath(misc::toQString(fi->path.string())); + addFile(path, fi->size, i); + fi++; + ++i; + } +- qDebug("real size: %ld, tree size: %ld", (long)t.total_size(), (long)root->getSize()); +- Q_ASSERT(root->getSize() == t.total_size()); ++ qDebug("real size: %ld, tree size: %ld", (long)t->total_size(), (long)root->getSize()); ++ Q_ASSERT(root->getSize() == t->total_size()); + } + +- arborescence(torrent_info t, std::vector<float> fp, int *prioritiesTab) { ++ arborescence(torrent_info const& t, std::vector<size_type> fp, int *prioritiesTab) { + torrent_info::file_iterator fi = t.begin_files(); + if(t.num_files() > 1) { + qDebug("More than one file in the torrent, setting a folder as root"); +@@ -200,13 +200,13 @@ + } else { + // XXX: Will crash if there is no file in torrent + qDebug("one file in the torrent, setting it as root with index 0"); +- root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0], prioritiesTab[0]); ++ root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0]/t.file_at(0).size, prioritiesTab[0]); + return; + } + int i = 0; + while(fi != t.end_files()) { + QString path = QDir::cleanPath(misc::toQString(fi->path.string())); +- addFile(path, fi->size, i, fp[i], prioritiesTab[i]); ++ addFile(path, fi->size, i, fp[i]/t.file_at(i).size, prioritiesTab[i]); + fi++; + ++i; + } +Index: src/properties_imp.cpp +=================================================================== +--- src/properties_imp.cpp (revision 2069) ++++ src/properties_imp.cpp (revision 2070) +@@ -102,7 +102,7 @@ + } + } + shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1))); +- std::vector<float> fp; ++ std::vector<size_type> fp; + h.file_progress(fp); + int *prioritiesTab = loadPiecesPriorities(); + // List files in torrent +@@ -669,11 +669,11 @@ + QFile incremental_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".incremental")); + incremental_file.open(QIODevice::WriteOnly | QIODevice::Text); + incremental_file.close(); +- h.set_sequenced_download_threshold(1); ++ h.set_sequential_download(true); + } + }else{ + QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental"); +- h.set_sequenced_download_threshold(100); // Disabled ++ h.set_sequential_download(false); + } + } + +Index: src/eventmanager.cpp +=================================================================== +--- src/eventmanager.cpp (revision 2069) ++++ src/eventmanager.cpp (revision 2070) +@@ -66,12 +66,6 @@ + case torrent_status::queued_for_checking: + event["state"] = QVariant("checking"); + break; +- case torrent_status::connecting_to_tracker: +- if(h.download_payload_rate() > 0) +- event["state"] = QVariant("downloading"); +- else +- event["state"] = QVariant("connecting"); +- break; + case torrent_status::downloading: + case torrent_status::downloading_metadata: + if(h.download_payload_rate() > 0) +@@ -113,12 +107,6 @@ + case torrent_status::queued_for_checking: + event["state"] = QVariant("checking"); + break; +- case torrent_status::connecting_to_tracker: +- if(h.download_payload_rate() > 0) +- event["state"] = QVariant("downloading"); +- else +- event["state"] = QVariant("connecting"); +- break; + case torrent_status::downloading: + case torrent_status::downloading_metadata: + if(h.download_payload_rate() > 0) +Index: src/previewSelect.h +=================================================================== +--- src/previewSelect.h (revision 2069) ++++ src/previewSelect.h (revision 2070) +@@ -90,7 +90,7 @@ + previewList->setItemDelegate(listDelegate); + previewList->header()->resizeSection(0, 200); + // Fill list in +- std::vector<float> fp; ++ std::vector<size_type> fp; + h.file_progress(fp); + unsigned int nbFiles = h.num_files(); + for(unsigned int i=0; i<nbFiles; ++i){ +@@ -101,7 +101,7 @@ + previewListModel->insertRow(row); + previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName)); + previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i))); +- previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i])); ++ previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]/h.filesize_at(i))); + indexes << i; + } + } +Index: src/Icons/skin/connecting.png +=================================================================== +Cannot display: file marked as a binary type. +svn:mime-type = application/octet-stream +Index: src/webui/scripts/client.js +=================================================================== +--- src/webui/scripts/client.js (revision 2069) ++++ src/webui/scripts/client.js (revision 2070) +@@ -44,8 +44,6 @@ + return '<img src="images/time.png"/>'; + case 'downloading': + return '<img src="images/skin/downloading.png"/>'; +- case 'connecting': +- return '<img src="images/skin/connecting.png"/>'; + case 'stalled': + return '<img src="images/skin/stalled.png"/>'; + case 'queued': +Index: src/bittorrent.cpp +=================================================================== +--- src/bittorrent.cpp (revision 2069) ++++ src/bittorrent.cpp (revision 2070) +@@ -28,7 +28,6 @@ + #include "bittorrent.h" + #include "misc.h" + #include "downloadThread.h" +-#include "deleteThread.h" + #include "filterParserThread.h" + + #include <libtorrent/extensions/metadata_transfer.hpp> +@@ -55,7 +54,7 @@ + s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0)); + } + // Set severity level of libtorrent session +- s->set_severity_level(alert::info); ++ s->set_alert_mask(alert::error_notification|alert::peer_notification|alert::port_mapping_notification|alert::storage_notification|alert::tracker_notification|alert::status_notification|alert::ip_block_notification); + // Enabling metadata plugin + s->add_extension(&create_metadata_plugin); + timerAlerts = new QTimer(); +@@ -68,8 +67,6 @@ + downloader = new downloadThread(this); + connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); + connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); +- // File deleter (thread) +- deleter = new deleteThread(this); + BigRatioTimer = 0; + filterParser = 0; + downloadQueue = 0; +@@ -94,7 +91,6 @@ + // Disable directory scanning + disableDirectoryScanning(); + // Delete our objects +- delete deleter; + delete fastResumeSaver; + delete timerAlerts; + if(BigRatioTimer) +@@ -123,16 +119,6 @@ + if(change) { + qDebug("PreAllocateAll changed, reloading all torrents!"); + preAllocateAll = b; +- // Reload All unfinished torrents +- QString hash; +- foreach(hash, unfinishedTorrents) { +- QTorrentHandle h = getTorrentHandle(hash); +- if(!h.is_valid()) { +- qDebug("/!\\ Error: Invalid handle"); +- continue; +- } +- reloadTorrent(h, b); +- } + } + } + +@@ -543,8 +529,7 @@ + QTorrentHandle h = getTorrentHandle(hash); + if(!h.is_valid()) return -1; + switch(h.state()) { +- case torrent_status::downloading: +- case torrent_status::connecting_to_tracker: { ++ case torrent_status::downloading: { + if(!TorrentsStartTime.contains(hash)) return -1; + int timeElapsed = TorrentsStartTime.value(hash).secsTo(QDateTime::currentDateTime()); + double avg_speed; +@@ -614,12 +599,11 @@ + } + QString savePath = h.save_path(); + QString fileName = h.name(); +- arborescence *files_arb = 0; +- if(permanent){ +- files_arb = new arborescence(h.get_torrent_info()); +- } + // Remove it from session +- s->remove_torrent(h.get_torrent_handle()); ++ if(permanent) ++ s->remove_torrent(h.get_torrent_handle(), session::delete_files); ++ else ++ s->remove_torrent(h.get_torrent_handle()); + // Remove it from torrent backup directory + QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); + QStringList filters; +@@ -666,12 +650,6 @@ + QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"); + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued")) + QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); +- if(permanent && files_arb != 0) { +- // Remove from Hard drive +- qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); +- // Deleting in a thread to avoid GUI freeze +- deleter->deleteTorrent(savePath, files_arb); +- } + if(permanent) + addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName)); + else +@@ -894,7 +872,6 @@ + // Add a torrent to the bittorrent session + void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) { + QTorrentHandle h; +- entry resume_data; + bool fastResume=false; + QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); + QString file, dest_file, scan_dir; +@@ -914,203 +891,164 @@ + } + Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive)); + qDebug("Adding %s to download list", file.toUtf8().data()); +- std::ifstream in(file.toUtf8().data(), std::ios_base::binary); +- in.unsetf(std::ios_base::skipws); +- try{ +- // Decode torrent file +- entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>()); +- // Getting torrent file informations +- boost::intrusive_ptr<torrent_info> t(new torrent_info(e)); +- qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str()); +- qDebug(" -> Name: %s", t->name().c_str()); +- QString hash = misc::toQString(t->info_hash()); +- if(file.startsWith(torrentBackup.path())) { ++ boost::intrusive_ptr<torrent_info> t; ++ try { ++ // Getting torrent file informations ++ t = new torrent_info(file.toUtf8().data()); ++ } catch(std::exception&) { ++ if(!from_url.isNull()) { ++ addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red")); ++ //emit invalidTorrent(from_url); ++ QFile::remove(file); ++ }else{ ++ addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red")); ++ //emit invalidTorrent(file); ++ } ++ addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red")); ++ if(fromScanDir) { ++ // Remove .corrupt file in case it already exists ++ QFile::remove(file+".corrupt"); ++ //Rename file extension so that it won't display error message more than once ++ QFile::rename(file,file+".corrupt"); ++ } ++ } ++ qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str()); ++ qDebug(" -> Name: %s", t->name().c_str()); ++ QString hash = misc::toQString(t->info_hash()); ++ if(file.startsWith(torrentBackup.path())) { + QFileInfo fi(file); + QString old_hash = fi.baseName(); + if(old_hash != hash){ +- qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data()); ++ qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data()); + } +- } +- if(s->find_torrent(t->info_hash()).is_valid()) { ++ } ++ // Check if torrent is already in download list ++ if(s->find_torrent(t->info_hash()).is_valid()) { + qDebug("/!\\ Torrent is already in download list"); + // Update info Bar + if(!fromScanDir) { +- if(!from_url.isNull()) { +- // If download from url, remove temp file +- QFile::remove(file); +- addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url)); +- //emit duplicateTorrent(from_url); +- }else{ +- addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file)); +- //emit duplicateTorrent(file); +- } ++ if(!from_url.isNull()) { ++ // If download from url, remove temp file ++ QFile::remove(file); ++ addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url)); ++ //emit duplicateTorrent(from_url); ++ }else{ ++ addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file)); ++ //emit duplicateTorrent(file); ++ } + }else{ +- // Delete torrent from scan dir +- QFile::remove(file); ++ // Delete torrent from scan dir ++ QFile::remove(file); + } + return; +- } +- //Getting fast resume data if existing +- if(torrentBackup.exists(hash+".fastresume")) { +- try{ +- std::stringstream strStream; +- strStream << hash.toStdString() << ".fastresume"; +- boost::filesystem::ifstream resume_file(fs::path(torrentBackup.path().toUtf8().data()) / strStream.str(), std::ios_base::binary); +- resume_file.unsetf(std::ios_base::skipws); +- resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>()); +- fastResume=true; +- }catch (invalid_encoding&) {} +- catch (fs::filesystem_error&) {} +- } +- QString savePath = getSavePath(hash); +- // Save save_path to hard drive +- QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath")); +- if(!savepath_file.exists()) { ++ } ++ add_torrent_params p; ++ //Getting fast resume data if existing ++ std::vector<char> buf; ++ if (load_file((torrentBackup.path()+hash+QString(".fastresume")).toUtf8().data(), buf) == 0) { ++ fastResume = true; ++ p.resume_data = &buf; ++ } ++ QString savePath = getSavePath(hash); ++ // Save save_path to hard drive ++ QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath")); ++ if(!savepath_file.exists()) { + savepath_file.open(QIODevice::WriteOnly | QIODevice::Text); + savepath_file.write(savePath.toUtf8()); + savepath_file.close(); +- } +- // Adding files to bittorrent session +- if(preAllocateAll) { +- h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_allocate, true); +- qDebug(" -> Full allocation mode"); +- }else{ +- h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_sparse, true); +- qDebug(" -> Sparse allocation mode"); +- } +- if(!h.is_valid()) { ++ } ++ p.save_path = savePath.toUtf8().data(); ++ p.ti = t; ++ // Preallocate all? ++ if(preAllocateAll) ++ p.storage_mode = storage_mode_allocate; ++ else ++ p.storage_mode = storage_mode_sparse; ++ // Start in pause ++ p.paused = true; ++ p.duplicate_is_error = false; // Already checked ++ p.auto_managed = true; ++ // Adding torrent to bittorrent session ++ h = s->add_torrent(p); ++ // Check if it worked ++ if(!h.is_valid()) { + // No need to keep on, it failed. + qDebug("/!\\ Error: Invalid handle"); + // If download from url, remove temp file + if(!from_url.isNull()) QFile::remove(file); + return; +- } +- // Connections limit per torrent +- h.set_max_connections(maxConnecsPerTorrent); +- // Uploads limit per torrent +- h.set_max_uploads(maxUploadsPerTorrent); +- // Load filtered files +- loadFilesPriorities(h); +- // Load custom url seeds +- loadWebSeeds(hash); +- // Load speed limit from hard drive +- loadTorrentSpeedLimits(hash); +- // Load ratio data +- loadDownloadUploadForTorrent(hash); +- // Load trackers +- bool loaded_trackers = loadTrackerFile(hash); +- // Doing this to order trackers well +- if(!loaded_trackers) { ++ } ++ // Connections limit per torrent ++ h.set_max_connections(maxConnecsPerTorrent); ++ // Uploads limit per torrent ++ h.set_max_uploads(maxUploadsPerTorrent); ++ // Load filtered files ++ loadFilesPriorities(h); ++ // Load custom url seeds ++ loadWebSeeds(hash); ++ // Load speed limit from hard drive ++ loadTorrentSpeedLimits(hash); ++ // Load ratio data ++ loadDownloadUploadForTorrent(hash); ++ // Load trackers ++ bool loaded_trackers = loadTrackerFile(hash); ++ // Doing this to order trackers well ++ if(!loaded_trackers) { + saveTrackerFile(hash); + loadTrackerFile(hash); +- } +- QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent"; +- if(file != newFile) { ++ } ++ QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent"; ++ if(file != newFile) { + // Delete file from torrentBackup directory in case it exists because + // QFile::copy() do not overwrite + QFile::remove(newFile); + // Copy it to torrentBackup directory + QFile::copy(file, newFile); +- } +- // Incremental download +- if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) { ++ } ++ // Incremental download ++ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) { + qDebug("Incremental download enabled for %s", t->name().c_str()); +- h.set_sequenced_download_threshold(1); +- } +- if((resumed || !addInPause) && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) { ++ h.set_sequential_download(true); ++ } ++ if((resumed || !addInPause) && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) { + // Start torrent because it was added in paused state + h.resume(); +- } +- if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { ++ } ++ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { + finishedTorrents << hash; + if(!resumed && queueingEnabled) { +- uploadQueue->append(hash); +- saveTorrentPriority(hash, uploadQueue->size()-1); +- updateUploadQueue(); ++ uploadQueue->append(hash); ++ saveTorrentPriority(hash, uploadQueue->size()-1); ++ updateUploadQueue(); + } +- }else{ ++ }else{ + unfinishedTorrents << hash; + if(!resumed && queueingEnabled) { +- downloadQueue->append(hash); +- saveTorrentPriority(hash, downloadQueue->size()-1); +- updateDownloadQueue(); ++ downloadQueue->append(hash); ++ saveTorrentPriority(hash, downloadQueue->size()-1); ++ updateDownloadQueue(); + } +- } +- // If download from url, remove temp file +- if(!from_url.isNull()) QFile::remove(file); +- // Delete from scan dir to avoid trying to download it again +- if(fromScanDir) { ++ } ++ // If download from url, remove temp file ++ if(!from_url.isNull()) QFile::remove(file); ++ // Delete from scan dir to avoid trying to download it again ++ if(fromScanDir) { + QFile::remove(file); +- } +- // Send torrent addition signal +- if(!from_url.isNull()) { ++ } ++ // Send torrent addition signal ++ if(!from_url.isNull()) { + emit addedTorrent(h); + if(fastResume) +- addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url)); ++ addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url)); + else +- addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url)); +- }else{ ++ addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url)); ++ }else{ + emit addedTorrent(h); + if(fastResume) +- addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file)); ++ addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file)); + else +- addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file)); +- } +- }catch (invalid_encoding& e) { // Raised by bdecode() +- std::cerr << "Could not decode file, reason: " << e.what() << '\n'; +- // Display warning to tell user we can't decode the torrent file +- if(!from_url.isNull()) { +- addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red")); +- //emit invalidTorrent(from_url); +- QFile::remove(file); +- }else{ +- addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red")); +- //emit invalidTorrent(file); +- } +- addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red")); +- if(fromScanDir) { +- // Remove .corrupt file in case it already exists +- QFile::remove(file+".corrupt"); +- //Rename file extension so that it won't display error message more than once +- QFile::rename(file,file+".corrupt"); +- } ++ addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file)); + } +- catch (invalid_torrent_file&) { // Raised by torrent_info constructor +- // Display warning to tell user we can't decode the torrent file +- if(!from_url.isNull()) { +- addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red")); +- //emit invalidTorrent(from_url); +- qDebug("File path is: %s", file.toUtf8().data()); +- QFile::remove(file); +- }else{ +- addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red")); +- //emit invalidTorrent(file); +- } +- if(fromScanDir) { +- // Remove .corrupt file in case it already exists +- QFile::remove(file+".corrupt"); <<Diff was trimmed, longer than 597 lines>> _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit