Add option to rename torrent from WebUI

Addresses #6815.
This commit is contained in:
Thomas Piccirello 2017-07-04 05:54:43 -04:00 committed by Vladimir Golovnev (qlassez)
parent 1b8cda7924
commit 798c230634
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
7 changed files with 115 additions and 0 deletions

View file

@ -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);