mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Require torrent category creation to be explicit
This commit is contained in:
committed by
sledgehammer999
parent
e29ab0087b
commit
435daaceed
@@ -811,6 +811,10 @@ void TorrentsController::setCategoryAction()
|
||||
const QString category {params()["category"].trimmed()};
|
||||
applyToTorrents(hashes, [category](BitTorrent::TorrentHandle *torrent)
|
||||
{
|
||||
auto *session = BitTorrent::Session::instance();
|
||||
const QStringList categories = session->categories().keys();
|
||||
if (!categories.contains(category) && !session->addCategory(category))
|
||||
throw APIError(APIErrorType::Conflict, tr("Unable to create category"));
|
||||
if (!torrent->setCategory(category))
|
||||
throw APIError(APIErrorType::Conflict, tr("Incorrect category name"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user