mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 13:48:05 -06:00
Use QSaveFile wherever applicable
expected.hpp was fetched from:
b803e3c07b/include/nonstd/expected.hpp
This commit is contained in:
@@ -30,13 +30,11 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#include <libtorrent/create_torrent.hpp>
|
||||
#include <libtorrent/file_storage.hpp>
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QHash>
|
||||
|
||||
@@ -209,16 +207,9 @@ void TorrentCreatorThread::run()
|
||||
checkInterruptionRequested();
|
||||
|
||||
// create the torrent
|
||||
QFile outfile {m_params.savePath};
|
||||
if (!outfile.open(QIODevice::WriteOnly))
|
||||
throw RuntimeError(outfile.errorString());
|
||||
|
||||
checkInterruptionRequested();
|
||||
|
||||
lt::bencode(Utils::IO::FileDeviceOutputIterator {outfile}, entry);
|
||||
if (outfile.error() != QFileDevice::NoError)
|
||||
throw RuntimeError(outfile.errorString());
|
||||
outfile.close();
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(m_params.savePath, entry);
|
||||
if (!result)
|
||||
throw RuntimeError(result.error());
|
||||
|
||||
emit updateProgress(100);
|
||||
emit creationSuccess(m_params.savePath, parentPath);
|
||||
|
||||
Reference in New Issue
Block a user