fetchtorrent: check JSON config usage correctly

The arguments to `fetchtorrent` are supposed to throw an error if the
user attempts to specify JSON configuration when they're not using the
transmission backend, however a logic error means the error will never
be thrown.

Move the test to somewhere where the behaviour will actually be checked.
This commit is contained in:
Adam Dinwoodie 2025-08-09 18:31:14 +01:00
parent f632635221
commit 613a98461f

View File

@ -18,11 +18,7 @@ in
"bittorrent" "bittorrent"
else else
"bittorrent-" + builtins.head (builtins.match urlRegexp url), "bittorrent-" + builtins.head (builtins.match urlRegexp url),
config ? config ? { },
if (backend == "transmission") then
{ }
else
throw "json config for configuring fetchFromBitorrent only works with the transmission backend",
hash, hash,
backend ? "transmission", backend ? "transmission",
recursiveHash ? true, recursiveHash ? true,
@ -44,6 +40,9 @@ let
''; '';
jsonConfig = (formats.json { }).generate "jsonConfig" config; jsonConfig = (formats.json { }).generate "jsonConfig" config;
in in
assert lib.assertMsg (config != { } -> backend == "transmission") ''
json config for configuring fetchtorrent only works with the transmission backend
'';
runCommand name runCommand name
{ {
inherit meta; inherit meta;