Gen 331: fixed some edge cases in garbage-collect

This commit is contained in:
pagedMov
2024-10-11 02:05:14 -04:00
parent 3586a5cd3c
commit f3a8370799
2 changed files with 12 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
echo "\033[1;4;38;2;230;69;83mThis process is irreversible.\033[0m Are you sure?"
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "Sweeping system...";scheck && runbg aplay "$HOME/media/sound/sys/collectgarbage.wav";break;;
@@ -12,10 +12,15 @@ done
output=$(nix-collect-garbage | tee /dev/tty)
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
rm_freed=$(du ~/.local/share/Trash/files/* ~/steamlib/.Trash-1000/files/* 2> /dev/null | awk '{sum += $1} END {print sum}')
rm_freed=$(echo "scale=2; $rm_freed / 1000" | bc)
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files/*
/run/current-system/sw/bin/rm -rfv ~/steamlib/.Trash-1000/files/*
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
rm_freed=$(du ~/.local/share/Trash/files 2> /dev/null)
rm_freed=$(echo "scale=2; $rm_freed / 1000" | bc)
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files
mkdir ~/.local/share/Trash/files
else
rm_freed="0"
fi
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
echo "System cleaning complete, freed $total_freed MiB in total"
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed MiB\033[0m in total"
scheck && runbg aplay "$HOME/media/sound/sys/rm.wav"

View File

@@ -11,7 +11,7 @@ git diff --quiet
if [ $? -eq 0 ]; then
scheck && runbg aplay ~/media/sound/sys/warning.wav
echo "Nothing to commit"
return
exit
fi
git add .
git commit -m "Gen $gen: $@"