Browse Source

Support loading multiple magnets/hashes/urls per .magnet file in the watched folder(one per line). Closes #217.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
56ca80eb78
  1. 11
      src/base/scanfoldersmodel.cpp

11
src/base/scanfoldersmodel.cpp

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include <QString>
#include <QStringList>
#include <QTemporaryFile>
#include <QTextStream>
#include "utils/misc.h"
#include "utils/fs.h"
@ -321,9 +322,13 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList) @@ -321,9 +322,13 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
if (file.endsWith(".magnet")) {
QFile f(file);
if (f.open(QIODevice::ReadOnly)) {
BitTorrent::Session::instance()->addTorrent(QString::fromLocal8Bit(f.readAll()), params);
f.remove();
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream str(&f);
while (!str.atEnd())
BitTorrent::Session::instance()->addTorrent(str.readLine(), params);
f.close();
Utils::Fs::forceRemove(file);
}
else {
qDebug("Failed to open magnet file: %s", qPrintable(f.errorString()));

Loading…
Cancel
Save