summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoron Behar <doron.behar@gmail.com>2023-10-10 22:45:15 +0000
committerGitHub <noreply@github.com>2023-10-10 22:45:15 +0000
commite33c5c3610260ac9f03d81228d5533be3a25dcef (patch)
tree07cd2d49f7b966a60ba834956a9e4e3f8916b42d
parentMerge pull request #260219 from aaronjheng/cargo-spellcheck (diff)
downloadnixpkgs-origin/revert-259259-syncthing_stale.tar.gz
Revert "nixos/syncthing: match stale ids by subtracting in jq"origin/revert-259259-syncthing_stale
-rw-r--r--nixos/modules/services/networking/syncthing.nix14
-rw-r--r--nixos/tests/syncthing-init.nix1
2 files changed, 8 insertions, 7 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index d3f6853424c8..346b50700c79 100644
--- a/nixos/modules/services/networking/syncthing.nix
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -100,13 +100,13 @@ let
the Nix configured list of IDs
*/
+ lib.optionalString s.override ''
- stale_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq} \
- --argjson new_ids ${lib.escapeShellArg (builtins.toJSON s.new_conf_IDs)} \
- --raw-output \
- '[.[].${s.GET_IdAttrName}] - $new_ids | .[]'
- )"
- for id in ''${stale_${conf_type}_ids}; do
- curl -X DELETE ${s.baseAddress}/$id
+ old_conf_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq} --raw-output '.[].${s.GET_IdAttrName}')"
+ for id in ''${old_conf_${conf_type}_ids}; do
+ if echo ${lib.concatStringsSep " " s.new_conf_IDs} | grep -q $id; then
+ continue
+ else
+ curl -X DELETE ${s.baseAddress}/$id
+ fi
done
''
))
diff --git a/nixos/tests/syncthing-init.nix b/nixos/tests/syncthing-init.nix
index 97fcf2ad28d1..195c157ffb6e 100644
--- a/nixos/tests/syncthing-init.nix
+++ b/nixos/tests/syncthing-init.nix
@@ -1,6 +1,7 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: let
testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
+ testName = "testDevice foo'bar";
in {
name = "syncthing-init";