Notify user when torrent moving finished

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-07-26 14:31:58 +03:00
parent 2a638d16e0
commit bac7fbc68e
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
4 changed files with 26 additions and 3 deletions

View file

@ -4699,10 +4699,13 @@ void Session::handleStorageMovedAlert(const lt::storage_moved_alert *p)
Q_ASSERT(newPath == currentJob.path);
const InfoHash infoHash = currentJob.torrentHandle.info_hash();
const TorrentHandleImpl *torrent = m_torrents.value(infoHash);
TorrentHandleImpl *torrent = m_torrents.value(infoHash);
const QString torrentName = (torrent ? torrent->name() : QString {infoHash});
LogMsg(tr("\"%1\" is successfully moved to \"%2\".").arg(torrentName, newPath));
if (torrent)
emit torrentStorageMoveFinished(torrent, newPath);
handleMoveTorrentStorageJobFinished();
}
@ -4714,11 +4717,15 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert
Q_ASSERT(currentJob.torrentHandle == p->handle);
const InfoHash infoHash = currentJob.torrentHandle.info_hash();
const TorrentHandleImpl *torrent = m_torrents.value(infoHash);
TorrentHandleImpl *torrent = m_torrents.value(infoHash);
const QString torrentName = (torrent ? torrent->name() : QString {infoHash});
const QString currentLocation = QString::fromStdString(p->handle.status(lt::torrent_handle::query_save_path).save_path);
const QString errorMessage = QString::fromStdString(p->message());
LogMsg(tr("Failed to move \"%1\" from \"%2\" to \"%3\". Reason: %4.")
.arg(torrentName, currentLocation, currentJob.path, QString::fromStdString(p->message())), Log::CRITICAL);
.arg(torrentName, currentLocation, currentJob.path, errorMessage), Log::CRITICAL);
if (torrent)
emit torrentStorageMoveFailed(torrent, currentJob.path, errorMessage);
handleMoveTorrentStorageJobFinished();
}