mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 23:17:21 -06:00
Vavious Magnet link related fixes
This commit is contained in:
@@ -772,7 +772,9 @@ void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
|
|||||||
const QString &fileName = h.name();
|
const QString &fileName = h.name();
|
||||||
// Remove it from session
|
// Remove it from session
|
||||||
if(delete_local_files) {
|
if(delete_local_files) {
|
||||||
savePathsToRemove[hash] = h.save_path();
|
QDir save_dir(h.save_path());
|
||||||
|
if(save_dir != QDir(defaultSavePath) && (defaultTempPath.isEmpty() || save_dir != QDir(defaultTempPath)))
|
||||||
|
savePathsToRemove[hash] = save_dir.absolutePath();
|
||||||
s->remove_torrent(h.get_torrent_handle(), session::delete_files);
|
s->remove_torrent(h.get_torrent_handle(), session::delete_files);
|
||||||
} else {
|
} else {
|
||||||
s->remove_torrent(h.get_torrent_handle());
|
s->remove_torrent(h.get_torrent_handle());
|
||||||
@@ -883,10 +885,6 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
|
|||||||
qDebug("addMagnetURI: Temp folder is enabled.");
|
qDebug("addMagnetURI: Temp folder is enabled.");
|
||||||
qDebug("addTorrent::Temp folder is enabled.");
|
qDebug("addTorrent::Temp folder is enabled.");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
if(!torrent_name.isEmpty()) {
|
|
||||||
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
|
|
||||||
torrent_tmp_path += torrent_name;
|
|
||||||
}
|
|
||||||
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
||||||
// Check if save path exists, creating it otherwise
|
// Check if save path exists, creating it otherwise
|
||||||
if(!QDir(torrent_tmp_path).exists())
|
if(!QDir(torrent_tmp_path).exists())
|
||||||
@@ -2073,7 +2071,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
QString old_path = old_path_parts.join("/");
|
QString old_path = old_path_parts.join("/");
|
||||||
QStringList new_path_parts = misc::toQStringU(p->name).split("/");
|
QStringList new_path_parts = misc::toQStringU(p->name).split("/");
|
||||||
new_path_parts.removeLast();
|
new_path_parts.removeLast();
|
||||||
if(old_path != new_path_parts.join("/")) {
|
if(!new_path_parts.isEmpty() && old_path != new_path_parts.join("/")) {
|
||||||
|
qDebug("Old_path(%s) != new_path(%s)", qPrintable(old_path), qPrintable(new_path_parts.join("/")));
|
||||||
old_path = h.save_path()+"/"+old_path;
|
old_path = h.save_path()+"/"+old_path;
|
||||||
qDebug("Detected folder renaming, attempt to delete old folder: %s", qPrintable(old_path));
|
qDebug("Detected folder renaming, attempt to delete old folder: %s", qPrintable(old_path));
|
||||||
QDir().rmpath(old_path);
|
QDir().rmpath(old_path);
|
||||||
@@ -2127,12 +2126,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
const QString& old_save_path = TorrentPersistentData::getPreviousPath(h.hash());
|
const QString& old_save_path = TorrentPersistentData::getPreviousPath(h.hash());
|
||||||
const QString new_save_path = QString::fromLocal8Bit(p->path.c_str());
|
const QString new_save_path = QString::fromLocal8Bit(p->path.c_str());
|
||||||
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
|
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
|
||||||
qDebug("Attempting to remove %s", qPrintable(old_save_path));
|
|
||||||
QDir old_save_dir(old_save_path);
|
QDir old_save_dir(old_save_path);
|
||||||
if(old_save_dir != QDir(defaultSavePath) && old_save_dir != QDir(defaultTempPath))
|
if(old_save_dir != QDir(defaultSavePath) && old_save_dir != QDir(defaultTempPath)) {
|
||||||
|
qDebug("Attempting to remove %s", qPrintable(old_save_path));
|
||||||
misc::removeEmptyTree(old_save_path);
|
misc::removeEmptyTree(old_save_path);
|
||||||
if(!new_save_path.startsWith(defaultTempPath))
|
}
|
||||||
|
if(defaultTempPath.isEmpty() || !new_save_path.startsWith(defaultTempPath)) {
|
||||||
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
||||||
|
}
|
||||||
emit savePathChanged(h);
|
emit savePathChanged(h);
|
||||||
//h.force_recheck();
|
//h.force_recheck();
|
||||||
}
|
}
|
||||||
@@ -2173,6 +2174,21 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// Truncate root folder
|
// Truncate root folder
|
||||||
const QString &root_folder = misc::truncateRootFolder(p->handle);
|
const QString &root_folder = misc::truncateRootFolder(p->handle);
|
||||||
TorrentPersistentData::setRootFolder(h.hash(), root_folder);
|
TorrentPersistentData::setRootFolder(h.hash(), root_folder);
|
||||||
|
|
||||||
|
// Move to a subfolder corresponding to the torrent root folder if necessary
|
||||||
|
if(!root_folder.isEmpty()) {
|
||||||
|
if(!h.is_seed() && !defaultTempPath.isEmpty()) {
|
||||||
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
|
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
|
||||||
|
torrent_tmp_path += root_folder;
|
||||||
|
h.move_storage(torrent_tmp_path);
|
||||||
|
} else {
|
||||||
|
QString save_path = h.save_path().replace("\\", "/");
|
||||||
|
if(!save_path.endsWith("/")) save_path += "/";
|
||||||
|
save_path += root_folder;
|
||||||
|
h.move_storage(save_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
emit metadataReceived(h);
|
emit metadataReceived(h);
|
||||||
if(h.is_paused()) {
|
if(h.is_paused()) {
|
||||||
// XXX: Unfortunately libtorrent-rasterbar does not send a torrent_paused_alert
|
// XXX: Unfortunately libtorrent-rasterbar does not send a torrent_paused_alert
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
|
|||||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||||
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
|
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
|
||||||
|
connect(BTSession, SIGNAL(metadataReceived(QTorrentHandle&)), this, SLOT(updateTorrentInfos(QTorrentHandle&)));
|
||||||
|
|
||||||
// Downloaded pieces progress bar
|
// Downloaded pieces progress bar
|
||||||
downloaded_pieces = new DownloadedPiecesBar(this);
|
downloaded_pieces = new DownloadedPiecesBar(this);
|
||||||
@@ -226,6 +227,12 @@ void PropertiesWidget::updateSavePath(QTorrentHandle& _h) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::updateTorrentInfos(QTorrentHandle& _h) {
|
||||||
|
if(h.is_valid() && h == _h) {
|
||||||
|
loadTorrentInfos(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesWidget::on_reannounce_btn_clicked() {
|
void PropertiesWidget::on_reannounce_btn_clicked() {
|
||||||
if(h.is_valid()) {
|
if(h.is_valid()) {
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
@@ -243,18 +250,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Save path
|
// Save path
|
||||||
QString p;
|
updateSavePath(h);
|
||||||
if(h.has_metadata() && h.num_files() == 1) {
|
changeSavePathButton->setEnabled(h.has_metadata());
|
||||||
p = h.firstFileSavePath();
|
|
||||||
} else {
|
|
||||||
p = TorrentPersistentData::getSavePath(h.hash());
|
|
||||||
if(p.isEmpty())
|
|
||||||
p = h.save_path();
|
|
||||||
}
|
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
p = p.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
save_path->setText(p);
|
|
||||||
// Creation date
|
// Creation date
|
||||||
lbl_creationDate->setText(h.creation_date());
|
lbl_creationDate->setText(h.creation_date());
|
||||||
// Hash
|
// Hash
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void loadTorrentInfos(QTorrentHandle &h);
|
void loadTorrentInfos(QTorrentHandle &h);
|
||||||
|
void updateTorrentInfos(QTorrentHandle &h);
|
||||||
void loadUrlSeeds();
|
void loadUrlSeeds();
|
||||||
void on_main_infos_button_clicked();
|
void on_main_infos_button_clicked();
|
||||||
void on_trackers_button_clicked();
|
void on_trackers_button_clicked();
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ public:
|
|||||||
|
|
||||||
static void saveSavePath(QString hash, QString save_path) {
|
static void saveSavePath(QString hash, QString save_path) {
|
||||||
Q_ASSERT(!hash.isEmpty());
|
Q_ASSERT(!hash.isEmpty());
|
||||||
|
qDebug("TorrentPersistentData::saveSavePath(%s)", qPrintable(save_path));
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||||
|
|||||||
Reference in New Issue
Block a user