From aadf961184b068f62cdf4090952730ad92344ad7 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 26 Jun 2022 19:25:48 +0800 Subject: [PATCH 1/2] Fix filename not populated correctly Fix up dd1bd8ad10fae86837e2c26132de92707622f08a. Related #17279. --- src/gui/torrentcreatordialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 86e941344..c91953be5 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -180,8 +180,8 @@ void TorrentCreatorDialog::onCreateButtonClicked() } // get save path - const Path savePath = m_storeLastSavePath.get(Utils::Fs::homePath() / Path(inputPath.filename() + u".torrent")); - Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), savePath.data(), tr("Torrent Files (*.torrent)"))}; + const Path lastSavePath = (m_storeLastSavePath.get(Utils::Fs::homePath()) / Path(inputPath.filename() + u".torrent")); + Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), lastSavePath.data(), tr("Torrent Files (*.torrent)"))}; if (destPath.isEmpty()) return; if (!destPath.hasExtension(TORRENT_FILE_EXTENSION)) From 34091176d582620f2b6e934214992117cbf8f108 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 27 Jun 2022 14:34:18 +0800 Subject: [PATCH 2/2] Fix wrong root path generated on Windows Fix cannot create torrent when the source file is at the root of a drive. Fix created torrent cannot be seeded when the source file is at the root of a drive. Fix up dd1bd8ad10fae86837e2c26132de92707622f08a. Closes #17279. --- src/base/path.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/base/path.cpp b/src/base/path.cpp index 0fa65d11a..dee1c50c4 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -115,6 +115,11 @@ Path Path::rootItem() const if (slashIndex == 0) // *nix absolute path return createUnchecked(u"/"_qs); +#ifdef Q_OS_WIN + // should be `c:/` instead of `c:` + if (m_pathStr.at(slashIndex - 1) == u':') + return createUnchecked(m_pathStr.left(slashIndex + 1)); +#endif return createUnchecked(m_pathStr.left(slashIndex)); } @@ -127,6 +132,12 @@ Path Path::parentPath() const if (slashIndex == 0) // *nix absolute path return (m_pathStr.size() == 1) ? Path() : createUnchecked(u"/"_qs); +#ifdef Q_OS_WIN + // should be `c:/` instead of `c:` + // Windows "drive letter" is limited to one alphabet + if ((slashIndex == 2) && (m_pathStr.at(1) == u':')) + return createUnchecked(m_pathStr.left(slashIndex + 1)); +#endif return createUnchecked(m_pathStr.left(slashIndex)); }