diff options
author | sefidel <contact@sefidel.net> | 2023-02-05 12:40:33 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2023-02-05 12:40:33 +0900 |
commit | 4a2af09922ca67b0c0b4691cb8b407c017aa97a9 (patch) | |
tree | 4a06c9a0a2ac3140ed04af7dfa3887b38200ac09 /colmena | |
parent | 02197dd0f141ad5b2bc1e7a668d402320f4df60a (diff) | |
download | nixrc-4a2af09922ca67b0c0b4691cb8b407c017aa97a9.tar.gz nixrc-4a2af09922ca67b0c0b4691cb8b407c017aa97a9.zip |
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.
Diffstat (limited to 'colmena')
-rw-r--r-- | colmena/cobalt/services/gitolite.nix | 9 |
1 files changed, 6 insertions, 3 deletions
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" ''; |