Last active
November 29, 2023 01:18
-
-
Save ivan/48c0c4fe156b0d348f4b725b3847e9af to your computer and use it in GitHub Desktop.
nixpkgs: qbittorrent: default webui to sequential download, fix webui UI issues, search save paths as well, use Windows filename restrictions on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e9dba0519edc2e7674c69eeaca31746d50882386 Mon Sep 17 00:00:00 2001 | |
From: Ivan Kozik <ivan@ludios.org> | |
Date: Sat, 1 Dec 2018 06:51:31 +0000 | |
Subject: [PATCH] qbittorrent: add patches | |
--- | |
.../networking/p2p/qbittorrent/default.nix | 29 +++++++++++++- | |
.../webui-default-sequential-download.patch | 39 +++++++++++++++++++ | |
.../webui-filter-also-search-save-path.patch | 21 ++++++++++ | |
.../webui-longer-filter-timeout.patch | 16 ++++++++ | |
.../qbittorrent/windows-filename-rules.patch | 29 ++++++++++++++ | |
5 files changed, 132 insertions(+), 2 deletions(-) | |
create mode 100644 pkgs/applications/networking/p2p/qbittorrent/webui-default-sequential-download.patch | |
create mode 100644 pkgs/applications/networking/p2p/qbittorrent/webui-filter-also-search-save-path.patch | |
create mode 100644 pkgs/applications/networking/p2p/qbittorrent/webui-longer-filter-timeout.patch | |
create mode 100644 pkgs/applications/networking/p2p/qbittorrent/windows-filename-rules.patch | |
diff --git a/pkgs/applications/networking/p2p/qbittorrent/default.nix b/pkgs/applications/networking/p2p/qbittorrent/default.nix | |
index 38e1b7cfceb..f6cf1123e5f 100644 | |
--- a/pkgs/applications/networking/p2p/qbittorrent/default.nix | |
+++ b/pkgs/applications/networking/p2p/qbittorrent/default.nix | |
@@ -1,4 +1,4 @@ | |
-{ mkDerivation, lib, fetchFromGitHub, makeWrapper, pkg-config | |
+{ mkDerivation, lib, fetchFromGitHub, makeWrapper, pkg-config, perl | |
, boost, libtorrent-rasterbar, qtbase, qttools, qtsvg | |
, debugSupport ? false | |
, guiSupport ? true, dbus ? null # GUI (disable to run headless) | |
@@ -26,13 +26,38 @@ mkDerivation rec { | |
# NOTE: 2018-05-31: CMake is working but it is not officially supported | |
nativeBuildInputs = [ makeWrapper pkg-config ]; | |
- buildInputs = [ boost libtorrent-rasterbar qtbase qttools qtsvg ] | |
+ buildInputs = [ perl boost libtorrent-rasterbar qtbase qttools qtsvg ] | |
++ optional guiSupport dbus # D(esktop)-Bus depends on GUI support | |
++ optional trackerSearch python3; | |
# Otherwise qm_gen.pri assumes lrelease-qt5, which does not exist. | |
QMAKE_LRELEASE = "lrelease"; | |
+ patches = [ | |
+ ./windows-filename-rules.patch | |
+ ./webui-default-sequential-download.patch | |
+ ./webui-longer-filter-timeout.patch | |
+ ./webui-filter-also-search-save-path.patch | |
+ ]; | |
+ | |
+ postPatch = '' | |
+ # Download torrents sequentially by default so that we can stream video | |
+ substituteInPlace src/base/bittorrent/addtorrentparams.h \ | |
+ --replace 'bool sequential = false;' \ | |
+ 'bool sequential = true;' | |
+ | |
+ # webui: remove "pause all" and "resume all" menu items that are too close | |
+ # to the add torrent buttons | |
+ sed -i -r 's,<li><a id="resumeAllLink">.+?</li>,,g' src/webui/www/private/index.html | |
+ sed -i -r 's,<li><a id="pauseAllLink">.+?</li>,,g' src/webui/www/private/index.html | |
+ | |
+ # webui: make text black instead of gray | |
+ sed -i -r 's/color: #555;/color: #000;/g' src/webui/www/private/css/style.css | |
+ | |
+ # webui: don't alternate row background color | |
+ perl -0777 -i -pe 's/\.dynamicTable tbody tr\.alt \{\n.*?\n}/.dynamicTable tbody tr.alt {}/gs' src/webui/www/private/css/dynamicTable.css | |
+ ''; | |
+ | |
configureFlags = [ | |
"--with-boost-libdir=${boost.out}/lib" | |
"--with-boost=${boost.dev}" ] | |
diff --git a/pkgs/applications/networking/p2p/qbittorrent/webui-default-sequential-download.patch b/pkgs/applications/networking/p2p/qbittorrent/webui-default-sequential-download.patch | |
new file mode 100644 | |
index 00000000000..2bd25e4439e | |
--- /dev/null | |
+++ b/pkgs/applications/networking/p2p/qbittorrent/webui-default-sequential-download.patch | |
@@ -0,0 +1,39 @@ | |
+diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp | |
+index 45edc13e1..ec1d31f9c 100644 | |
+--- a/src/webui/api/torrentscontroller.cpp | |
++++ b/src/webui/api/torrentscontroller.cpp | |
+@@ -606,7 +606,7 @@ void TorrentsController::addAction() | |
+ const QString cookie = params()["cookie"]; | |
+ | |
+ const bool skipChecking = parseBool(params()["skip_checking"]).value_or(false); | |
+- const bool seqDownload = parseBool(params()["sequentialDownload"]).value_or(false); | |
++ const bool seqDownload = parseBool(params()["sequentialDownload"]).value_or(true); | |
+ const bool firstLastPiece = parseBool(params()["firstLastPiecePrio"]).value_or(false); | |
+ const std::optional<bool> addPaused = parseBool(params()["paused"]); | |
+ const QString savepath = params()["savepath"].trimmed(); | |
+diff --git a/src/webui/www/private/download.html b/src/webui/www/private/download.html | |
+index bf5b16708..c6e5107c0 100644 | |
+--- a/src/webui/www/private/download.html | |
++++ b/src/webui/www/private/download.html | |
+@@ -101,7 +101,7 @@ | |
+ <label for="sequentialDownload">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label> | |
+ </td> | |
+ <td> | |
+- <input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" /> | |
++ <input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" checked /> | |
+ </td> | |
+ </tr> | |
+ <tr> | |
+diff --git a/src/webui/www/private/upload.html b/src/webui/www/private/upload.html | |
+index ab4edd1f6..a24c34db7 100644 | |
+--- a/src/webui/www/private/upload.html | |
++++ b/src/webui/www/private/upload.html | |
+@@ -89,7 +89,7 @@ | |
+ <label for="sequentialDownload">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label> | |
+ </td> | |
+ <td> | |
+- <input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" /> | |
++ <input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" checked /> | |
+ </td> | |
+ </tr> | |
+ <tr> | |
diff --git a/pkgs/applications/networking/p2p/qbittorrent/webui-filter-also-search-save-path.patch b/pkgs/applications/networking/p2p/qbittorrent/webui-filter-also-search-save-path.patch | |
new file mode 100644 | |
index 00000000000..be725ca4a66 | |
--- /dev/null | |
+++ b/pkgs/applications/networking/p2p/qbittorrent/webui-filter-also-search-save-path.patch | |
@@ -0,0 +1,21 @@ | |
+diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js | |
+index e2d8c90ab..af7d9e34e 100644 | |
+--- a/src/webui/www/private/scripts/dynamicTable.js | |
++++ b/src/webui/www/private/scripts/dynamicTable.js | |
+@@ -1207,6 +1207,7 @@ window.qBittorrent.DynamicTable = (function() { | |
+ applyFilter: function(row, filterName, categoryHash, tagHash, trackerHash, filterTerms) { | |
+ const state = row['full_data'].state; | |
+ const name = row['full_data'].name.toLowerCase(); | |
++ const save_path = row['full_data'].save_path.toLowerCase(); | |
+ let inactive = false; | |
+ let r; | |
+ | |
+@@ -1316,7 +1317,7 @@ window.qBittorrent.DynamicTable = (function() { | |
+ } | |
+ | |
+ if ((filterTerms !== undefined) && (filterTerms !== null) | |
+- && (filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(name, filterTerms)) | |
++ && (filterTerms.length > 0) && !(window.qBittorrent.Misc.containsAllTerms(name, filterTerms) || window.qBittorrent.Misc.containsAllTerms(save_path, filterTerms))) | |
+ return false; | |
+ | |
+ return true; | |
diff --git a/pkgs/applications/networking/p2p/qbittorrent/webui-longer-filter-timeout.patch b/pkgs/applications/networking/p2p/qbittorrent/webui-longer-filter-timeout.patch | |
new file mode 100644 | |
index 00000000000..7f24c813583 | |
--- /dev/null | |
+++ b/pkgs/applications/networking/p2p/qbittorrent/webui-longer-filter-timeout.patch | |
@@ -0,0 +1,16 @@ | |
+diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js | |
+index 4a58f0021..cab2dbdd0 100644 | |
+--- a/src/webui/www/private/scripts/client.js | |
++++ b/src/webui/www/private/scripts/client.js | |
+@@ -1138,9 +1138,10 @@ window.addEvent('load', function() { | |
+ if (value !== prevTorrentsFilterValue) { | |
+ prevTorrentsFilterValue = value; | |
+ clearTimeout(torrentsFilterInputTimer); | |
++ let timeout = value.length >= 2 ? 400 : 1500; | |
+ torrentsFilterInputTimer = setTimeout(function() { | |
+ torrentsTable.updateTable(false); | |
+- }, 400); | |
++ }, timeout); | |
+ } | |
+ }); | |
+ | |
diff --git a/pkgs/applications/networking/p2p/qbittorrent/windows-filename-rules.patch b/pkgs/applications/networking/p2p/qbittorrent/windows-filename-rules.patch | |
new file mode 100644 | |
index 00000000000..b47a10f29c2 | |
--- /dev/null | |
+++ b/pkgs/applications/networking/p2p/qbittorrent/windows-filename-rules.patch | |
@@ -0,0 +1,29 @@ | |
+diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp | |
+index 1be3f98a2..6d7de6bfa 100644 | |
+--- a/src/base/utils/fs.cpp | |
++++ b/src/base/utils/fs.cpp | |
+@@ -248,22 +248,12 @@ bool Utils::Fs::isValidFileSystemName(const QString &name, const bool allowSepar | |
+ { | |
+ if (name.isEmpty()) return false; | |
+ | |
+-#if defined(Q_OS_WIN) | |
++ // Use the more-restrictive Windows rules on all operating systems | |
++ // to avoid problems when sharing files. | |
+ const QRegularExpression regex | |
+ {allowSeparators | |
+ ? QLatin1String("[:?\"*<>|]") | |
+ : QLatin1String("[\\\\/:?\"*<>|]")}; | |
+-#elif defined(Q_OS_MACOS) | |
+- const QRegularExpression regex | |
+- {allowSeparators | |
+- ? QLatin1String("[\\0:]") | |
+- : QLatin1String("[\\0/:]")}; | |
+-#else | |
+- const QRegularExpression regex | |
+- {allowSeparators | |
+- ? QLatin1String("[\\0]") | |
+- : QLatin1String("[\\0/]")}; | |
+-#endif | |
+ return !name.contains(regex); | |
+ } | |
+ | |
-- | |
2.33.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://github.com/ludios/qbittorrent instead