mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
* Add option to set torrent location from webui context menu (addresses #6815) * Update debug messages * Use logger * Remove redundant curly braces * Remove message * Use log message from transferlistwidget * Use QDir * Remove unused import * Check if newLocation is an empty string
This commit is contained in:
parent
145641ac41
commit
07a85a1018
8 changed files with 178 additions and 63 deletions
|
@ -34,6 +34,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "base/iconprovider.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/string.h"
|
||||
|
@ -117,6 +118,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
|||
ADD_ACTION(command, decreasePrio);
|
||||
ADD_ACTION(command, topPrio);
|
||||
ADD_ACTION(command, bottomPrio);
|
||||
ADD_ACTION(command, setLocation);
|
||||
ADD_ACTION(command, recheck);
|
||||
ADD_ACTION(command, setCategory);
|
||||
ADD_ACTION(command, addCategory);
|
||||
|
@ -774,6 +776,30 @@ void WebApplication::action_command_bottomPrio()
|
|||
BitTorrent::Session::instance()->bottomTorrentsPriority(hashes);
|
||||
}
|
||||
|
||||
void WebApplication::action_command_setLocation()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
CHECK_PARAMETERS("hashes" << "location");
|
||||
|
||||
QStringList hashes = request().posts["hashes"].split("|");
|
||||
QString newLocation = request().posts["location"].trimmed();
|
||||
|
||||
// check location exists
|
||||
if (newLocation.isEmpty() || !QDir(newLocation).exists())
|
||||
return;
|
||||
|
||||
foreach (const QString &hash, hashes) {
|
||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||
if (torrent) {
|
||||
// get old location
|
||||
const QString oldLocation = torrent->savePath();
|
||||
Logger::instance()->addMessage(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"").arg(torrent->name()).arg(torrent->savePath()).arg(newLocation));
|
||||
|
||||
torrent->move(Utils::Fs::expandPathAbs(newLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebApplication::action_command_recheck()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue