mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
allow setCommentAction() to take multiple hashes as an argument
This commit is contained in:
parent
ab0b35b9ca
commit
a15667dba1
2 changed files with 8 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## 2.12.1
|
## 2.12.1
|
||||||
* [#23031](https://github.com/qbittorrent/qBittorrent/pull/23031)
|
* [#23031](https://github.com/qbittorrent/qBittorrent/pull/23031)
|
||||||
* Add `torrents/setComment` endpoint with parameters `hash` and `comment` for setting a new torrent comment
|
* Add `torrents/setComment` endpoint with parameters `hashes` and `comment` for setting a new torrent comment
|
||||||
|
|
||||||
## 2.12.0
|
## 2.12.0
|
||||||
|
|
||||||
|
|
|
@ -2146,17 +2146,14 @@ void TorrentsController::onMetadataDownloaded(const BitTorrent::TorrentInfo &inf
|
||||||
|
|
||||||
void TorrentsController::setCommentAction()
|
void TorrentsController::setCommentAction()
|
||||||
{
|
{
|
||||||
requireParams({u"hash"_s, u"comment"_s});
|
requireParams({u"hashes"_s, u"comment"_s});
|
||||||
|
|
||||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||||
|
const QString comment = params()[u"comment"_s].trimmed()
|
||||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
|
||||||
if (!torrent)
|
|
||||||
throw APIError(APIErrorType::NotFound);
|
|
||||||
|
|
||||||
QString comment = params()[u"comment"_s].trimmed()
|
|
||||||
.replace(QRegularExpression(u"\r?\n"_s), u" "_s);
|
.replace(QRegularExpression(u"\r?\n"_s), u" "_s);
|
||||||
torrent->setComment(comment);
|
|
||||||
|
|
||||||
setResult(QString());
|
applyToTorrents(hashes, [&comment](BitTorrent::Torrent *const torrent)
|
||||||
|
{
|
||||||
|
torrent->setComment(comment);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue