diff --git a/src/base/scanfoldersmodel.cpp b/src/base/scanfoldersmodel.cpp index 784077741..310e21eca 100644 --- a/src/base/scanfoldersmodel.cpp +++ b/src/base/scanfoldersmodel.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "utils/misc.h" #include "utils/fs.h" @@ -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()));