mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-02-23 19:29:40 +08:00
Vavious Magnet link related fixes
This commit is contained in:
parent
bcdf4e42fa
commit
51068294f1
@ -772,7 +772,9 @@ void Bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
|
||||
const QString &fileName = h.name();
|
||||
// Remove it from session
|
||||
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);
|
||||
} else {
|
||||
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("addTorrent::Temp folder is enabled.");
|
||||
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();
|
||||
// Check if save path exists, creating it otherwise
|
||||
if(!QDir(torrent_tmp_path).exists())
|
||||
@ -2073,7 +2071,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||
QString old_path = old_path_parts.join("/");
|
||||
QStringList new_path_parts = misc::toQStringU(p->name).split("/");
|
||||
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;
|
||||
qDebug("Detected folder renaming, attempt to delete old folder: %s", qPrintable(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 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("Attempting to remove %s", qPrintable(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);
|
||||
if(!new_save_path.startsWith(defaultTempPath))
|
||||
}
|
||||
if(defaultTempPath.isEmpty() || !new_save_path.startsWith(defaultTempPath)) {
|
||||
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
||||
}
|
||||
emit savePathChanged(h);
|
||||
//h.force_recheck();
|
||||
}
|
||||
@ -2173,6 +2174,21 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||
// Truncate root folder
|
||||
const QString &root_folder = misc::truncateRootFolder(p->handle);
|
||||
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);
|
||||
if(h.is_paused()) {
|
||||
// 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(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
|
||||
connect(BTSession, SIGNAL(metadataReceived(QTorrentHandle&)), this, SLOT(updateTorrentInfos(QTorrentHandle&)));
|
||||
|
||||
// Downloaded pieces progress bar
|
||||
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() {
|
||||
if(h.is_valid()) {
|
||||
h.force_reannounce();
|
||||
@ -243,18 +250,8 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
||||
|
||||
try {
|
||||
// Save path
|
||||
QString p;
|
||||
if(h.has_metadata() && h.num_files() == 1) {
|
||||
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);
|
||||
updateSavePath(h);
|
||||
changeSavePathButton->setEnabled(h.has_metadata());
|
||||
// Creation date
|
||||
lbl_creationDate->setText(h.creation_date());
|
||||
// Hash
|
||||
|
@ -85,6 +85,7 @@ protected:
|
||||
|
||||
protected slots:
|
||||
void loadTorrentInfos(QTorrentHandle &h);
|
||||
void updateTorrentInfos(QTorrentHandle &h);
|
||||
void loadUrlSeeds();
|
||||
void on_main_infos_button_clicked();
|
||||
void on_trackers_button_clicked();
|
||||
|
@ -316,6 +316,7 @@ public:
|
||||
|
||||
static void saveSavePath(QString hash, QString save_path) {
|
||||
Q_ASSERT(!hash.isEmpty());
|
||||
qDebug("TorrentPersistentData::saveSavePath(%s)", qPrintable(save_path));
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
|
Loading…
Reference in New Issue
Block a user