From 4a2af09922ca67b0c0b4691cb8b407c017aa97a9 Mon Sep 17 00:00:00 2001 From: sefidel Date: Sun, 5 Feb 2023 12:40:33 +0900 Subject: feat(colmena/services): gitolite: don't remove parent dir When a user has multiple trashes with the same name, they will be located on the same parent directory. Thus, removing the parent directory has potential side effect of wiping ALL trashes for that repository name. --- colmena/cobalt/services/gitolite.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'colmena/cobalt/services') diff --git a/colmena/cobalt/services/gitolite.nix b/colmena/cobalt/services/gitolite.nix index 4461a30..459a80e 100644 --- a/colmena/cobalt/services/gitolite.nix +++ b/colmena/cobalt/services/gitolite.nix @@ -52,14 +52,17 @@ age=$(( $system_timestamp - $trash_timestamp )) # Wipe trashes older than 2w if [[ age -gt 1209600 ]] ; then - target_dir=$(rev <<< $dir | cut -d'/' -f2- | rev) - echo "Removing '$target_dir' (age $age)" - rm -rf $target_dir + echo "Removing '$dir' (age $age)" + rm -rf $dir ((removed_entry+=1)) fi ((processed_entry+=1)) done + echo "Directories that needs cleanup:" + find Trash -type d -empty -print -delete + echo "Cleaned empty directories." + echo "Done! Removed $removed_entry/$processed_entry" ''; -- cgit 1.4.1