mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Do not store created torrent in memory before writing it to a file (closes #133)
This commit is contained in:
parent
3bc85c29ae
commit
573dac0b91
@ -48,6 +48,8 @@
|
|||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
#if LIBTORRENT_VERSION_MINOR < 16
|
#if LIBTORRENT_VERSION_MINOR < 16
|
||||||
@ -127,17 +129,13 @@ void TorrentCreatorThread::run() {
|
|||||||
if (abort) return;
|
if (abort) return;
|
||||||
// create the torrent and print it to out
|
// create the torrent and print it to out
|
||||||
qDebug("Saving to %s", qPrintable(save_path));
|
qDebug("Saving to %s", qPrintable(save_path));
|
||||||
std::vector<char> torrent;
|
std::ofstream outfile(save_path.toLocal8Bit().constData());
|
||||||
bencode(back_inserter(torrent), t.generate());
|
if (outfile.fail())
|
||||||
QFile outfile(save_path);
|
throw std::exception();
|
||||||
if (!torrent.empty() && outfile.open(QIODevice::WriteOnly)) {
|
bencode(std::ostream_iterator<char>(outfile), t.generate());
|
||||||
outfile.write(&torrent[0], torrent.size());
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
emit updateProgress(100);
|
emit updateProgress(100);
|
||||||
emit creationSuccess(save_path, parent_path);
|
emit creationSuccess(save_path, parent_path);
|
||||||
} else {
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
emit creationFailure(QString::fromLocal8Bit(e.what()));
|
emit creationFailure(QString::fromLocal8Bit(e.what()));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user