From b98d0282ceaebd99ddba269338a9f78a5e40a5a9 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 24 Oct 2010 08:06:56 +0000 Subject: [PATCH] BUGFIX: Fix issue when altering files priorities of a seeding torrent (closes #665799) --- src/qtlibtorrent/qtorrenthandle.cpp | 33 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index e27588e00..660ba9e82 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -481,6 +481,32 @@ void QTorrentHandle::prioritize_files(const std::vector &v) { if(was_seed && !is_seed()) { // Reset seed status TorrentPersistentData::saveSeedStatus(*this); + // Move to temp folder if necessary + if(Preferences::isTempPathEnabled()) { + QString tmp_path = Preferences::getTempPath(); + QString root_folder = TorrentPersistentData::getRootFolder(hash()); + if(!root_folder.isEmpty()) + tmp_path = QDir(tmp_path).absoluteFilePath(root_folder); + move_storage(tmp_path); + } + } +} + +void QTorrentHandle::file_priority(int index, int priority) const { + Q_ASSERT(torrent_handle::is_valid()); + bool was_seed = is_seed(); + torrent_handle::file_priority(index, priority); + if(was_seed && !is_seed()) { + // Save seed status + TorrentPersistentData::saveSeedStatus(*this); + // Move to temp folder if necessary + if(Preferences::isTempPathEnabled()) { + QString tmp_path = Preferences::getTempPath(); + QString root_folder = TorrentPersistentData::getRootFolder(hash()); + if(!root_folder.isEmpty()) + tmp_path = QDir(tmp_path).absoluteFilePath(root_folder); + move_storage(tmp_path); + } } } @@ -500,13 +526,6 @@ void QTorrentHandle::move_storage(QString new_path) const { torrent_handle::move_storage(new_path.toLocal8Bit().constData()); } -void QTorrentHandle::file_priority(int index, int priority) const { - Q_ASSERT(torrent_handle::is_valid()); - torrent_handle::file_priority(index, priority); - // Save seed status - TorrentPersistentData::saveSeedStatus(*this); -} - bool QTorrentHandle::save_torrent_file(QString path) { if(!torrent_handle::has_metadata()) return false; QFile met_file(path);