Provide torrent creation feature via WebAPI

PR #20366.
Closes #5614.

Co-authored-by: Radu Carpa <radu.carpa@cern.ch>
This commit is contained in:
Vladimir Golovnev 2024-02-27 15:57:16 +03:00 committed by GitHub
parent 15697f904d
commit 0114610a40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 887 additions and 83 deletions

View file

@ -30,7 +30,6 @@
#include "downloadhandlerimpl.h"
#include <QtSystemDetection>
#include <QTemporaryFile>
#include <QUrl>
#include "base/3rdparty/expected.hpp"
@ -49,19 +48,6 @@
const int MAX_REDIRECTIONS = 20; // the common value for web browsers
namespace
{
nonstd::expected<Path, QString> saveToTempFile(const QByteArray &data)
{
QTemporaryFile file {Utils::Fs::tempPath().data()};
if (!file.open() || (file.write(data) != data.length()) || !file.flush())
return nonstd::make_unexpected(file.errorString());
file.setAutoRemove(false);
return Path(file.fileName());
}
}
Net::DownloadHandlerImpl::DownloadHandlerImpl(DownloadManager *manager
, const DownloadRequest &downloadRequest, const bool useProxy)
: DownloadHandler {manager}
@ -163,7 +149,7 @@ void Net::DownloadHandlerImpl::processFinishedDownload()
const Path destinationPath = m_downloadRequest.destFileName();
if (destinationPath.isEmpty())
{
const nonstd::expected<Path, QString> result = saveToTempFile(m_result.data);
const nonstd::expected<Path, QString> result = Utils::IO::saveToTempFile(m_result.data);
if (result)
{
m_result.filePath = result.value();