mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
parent
1b8cda7924
commit
798c230634
7 changed files with 115 additions and 0 deletions
|
@ -30,6 +30,8 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
#include <QCryptographicHash>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
|
@ -119,6 +121,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
|||
ADD_ACTION(command, topPrio);
|
||||
ADD_ACTION(command, bottomPrio);
|
||||
ADD_ACTION(command, setLocation);
|
||||
ADD_ACTION(command, rename);
|
||||
ADD_ACTION(command, recheck);
|
||||
ADD_ACTION(command, setCategory);
|
||||
ADD_ACTION(command, addCategory);
|
||||
|
@ -800,6 +803,25 @@ void WebApplication::action_command_setLocation()
|
|||
}
|
||||
}
|
||||
|
||||
void WebApplication::action_command_rename()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
CHECK_PARAMETERS("hash" << "name");
|
||||
|
||||
QString hash = request().posts["hash"];
|
||||
QString name = request().posts["name"].trimmed();
|
||||
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
if (torrent && !name.isEmpty()) {
|
||||
name.replace(QRegularExpression("\r?\n|\r"), " ");
|
||||
qDebug() << "Renaming" << torrent->name() << "to" << name;
|
||||
torrent->setName(name);
|
||||
}
|
||||
else {
|
||||
status(400, "Incorrect torrent hash or name");
|
||||
}
|
||||
}
|
||||
|
||||
void WebApplication::action_command_recheck()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue