bin/clean: improve log cleaning

This commit is contained in:
xeruf 2021-12-13 14:33:20 +01:00
parent c92d34463a
commit e3affa7c10
1 changed files with 19 additions and 17 deletions

View File

@ -13,10 +13,10 @@ dir="$("$local" 2>/dev/null || echo "$HOME")"
df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir" df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir"
highlight "home" highlight "clean home"
for f in ${_clean_folders[@]} for f in ${_clean_folders[@]}
do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")" do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")"
test -f $f || test -d $f && echo "Removing empty $f" && rm -rf $i $f test -f $f || test -d $f && echo "Removing superfluous $f" && rm -rf $i $f
done done
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
@ -30,7 +30,10 @@ for k in "${!_clean_map[@]}"; do
done done
highlight "s :: recursively remove logs" highlight "s :: recursively remove logs"
[[ $1 =~ "s" ]] && find \( -name "logs" -prune -o -name "crash-reports" -prune -o -iname "*log.txt" -o -name "*.log.*" -o -iname "*.log" \) -print -exec rm -rI {} + [[ $1 =~ "s" ]] && find \( -name ".git" -o -name "src" \) -prune -o \
\( \( -name "logs" -o -name "log" -o -name "crash-reports" \) -prune -o \
-type f \( -name "*.log.gz" -o -name "*.log.[0-9]" -o -iname "*.log" \) \) \
-print -exec rm -rI {} +
highlight "m :: recursively remove mac-files" highlight "m :: recursively remove mac-files"
if [[ $1 =~ "m" ]]; then if [[ $1 =~ "m" ]]; then
@ -38,7 +41,19 @@ if [[ $1 =~ "m" ]]; then
find -name '*.DS_Store' -delete find -name '*.DS_Store' -delete
fi fi
highlight "g :: clean gradle" highlight "d :: recursively remove development caches"
if [[ $1 =~ "d" ]]; then
find -name "src" -prune -o \
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
-print -exec rm $i -r {} + -prune
echo -n " " && highlight "build directories"
find $DATA/2-standards/dev/aur -mindepth 2 -maxdepth 2 -type d -not -name ".*" \
-print -exec sudo rm -rI {} +
find \( -name ".git" -o -path "*/mixxx/build" -o -name "Leaflet" -o -name "www" -o -name "src" \) \
-prune -o -name "build" -type d \
-print -exec rm -rI {} + -prune
fi
highlight "g :: clean gradle caches"
if [[ $1 =~ "g" ]]; then if [[ $1 =~ "g" ]]; then
find "${GRADLE_USER_HOME:-$HOME/.gradle}" -mindepth 1 -maxdepth 1 -type d -print -exec rm $i -r {} + find "${GRADLE_USER_HOME:-$HOME/.gradle}" -mindepth 1 -maxdepth 1 -type d -print -exec rm $i -r {} +
find $PROJECTS -name .gradle -print -exec rm $i -r {} + find $PROJECTS -name .gradle -print -exec rm $i -r {} +
@ -54,19 +69,6 @@ if test -f "/var/log/apt/history.log"; then
export aptclean_last=$aptclean_cur export aptclean_last=$aptclean_cur
fi fi
highlight "d :: recursively remove development caches"
if [[ $1 =~ "d" ]]; then
find -name "src" -prune -o \
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
-print -exec rm $i -r {} + -prune
echo -n " " && highlight "build directories"
find $DATA/2-standards/dev/aur -mindepth 2 -maxdepth 2 -type d -not -name ".*" \
-print -exec sudo rm -rI {} +
find \( -name ".git" -o -path "*/mixxx/build" -o -name "Leaflet" -o -name "www" -o -name "src" \) \
-prune -o -name "build" -type d \
-print -exec rm -rI {} + -prune
fi
highlight "o :: optimize space extensively" highlight "o :: optimize space extensively"
if [[ $1 =~ "o" ]]; then if [[ $1 =~ "o" ]]; then
which yay &>/dev/null && yay -Sc --noconfirm which yay &>/dev/null && yay -Sc --noconfirm