From 1e88650baeeee9ca4f7993f3e365b217fc2ffae7 Mon Sep 17 00:00:00 2001 From: Xu Chao Date: Sun, 27 Aug 2023 13:38:59 +0800 Subject: [PATCH] Open "Save path" if torrent has no metadata PR #19495. Closes #18738. --- src/gui/transferlistwidget.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 71c1e117e..38300d05c 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -100,13 +100,15 @@ namespace void openDestinationFolder(const BitTorrent::Torrent *const torrent) { + const Path contentPath = torrent->contentPath(); + const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath()); #ifdef Q_OS_MACOS - MacUtils::openFiles({torrent->contentPath()}); + MacUtils::openFiles({openedPath}); #else if (torrent->filesCount() == 1) - Utils::Gui::openFolderSelect(torrent->contentPath()); + Utils::Gui::openFolderSelect(openedPath); else - Utils::Gui::openPath(torrent->contentPath()); + Utils::Gui::openPath(openedPath); #endif } @@ -587,21 +589,22 @@ void TransferListWidget::openSelectedTorrentsFolder() const for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { const Path contentPath = torrent->contentPath(); - paths.insert(contentPath); + paths.insert(!contentPath.isEmpty() ? contentPath : torrent->savePath()); } MacUtils::openFiles(PathList(paths.cbegin(), paths.cend())); #else for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { const Path contentPath = torrent->contentPath(); - if (!paths.contains(contentPath)) + const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath()); + if (!paths.contains(openedPath)) { if (torrent->filesCount() == 1) - Utils::Gui::openFolderSelect(contentPath); + Utils::Gui::openFolderSelect(openedPath); else - Utils::Gui::openPath(contentPath); + Utils::Gui::openPath(openedPath); } - paths.insert(contentPath); + paths.insert(openedPath); } #endif // Q_OS_MACOS }