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

Loading…
Cancel
Save