mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
@@ -91,3 +91,8 @@ void APIController::setResult(const QJsonObject &result)
|
||||
{
|
||||
m_result = QJsonDocument(result);
|
||||
}
|
||||
|
||||
void APIController::setResult(const QByteArray &result)
|
||||
{
|
||||
m_result = result;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ protected:
|
||||
void setResult(const QString &result);
|
||||
void setResult(const QJsonArray &result);
|
||||
void setResult(const QJsonObject &result);
|
||||
void setResult(const QByteArray &result);
|
||||
|
||||
private:
|
||||
StringMap m_params;
|
||||
|
||||
@@ -1414,3 +1414,19 @@ void TorrentsController::renameFolderAction()
|
||||
throw APIError(APIErrorType::Conflict, error.message());
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentsController::exportAction()
|
||||
{
|
||||
requireParams({u"hash"_qs});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_qs]);
|
||||
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const nonstd::expected<QByteArray, QString> result = torrent->exportToBuffer();
|
||||
if (!result)
|
||||
throw APIError(APIErrorType::Conflict, tr("Unable to export torrent file. Error: %1").arg(result.error()));
|
||||
|
||||
setResult(result.value());
|
||||
}
|
||||
|
||||
@@ -87,4 +87,5 @@ private slots:
|
||||
void toggleFirstLastPiecePrioAction();
|
||||
void renameFileAction();
|
||||
void renameFolderAction();
|
||||
void exportAction();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user