1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/archbuild/files/clean-dests
Jan Alexander Steffens (heftig) 1902860609
clean-dests: Speed up
Try not to scan deep into directory trees and exit early if we find a
new enough file. An LLVM SVN checkout has a lot of files.

I don't think zsh glob can do this so reimplement in bash+find.
2019-02-17 02:05:17 +01:00

28 lines
558 B
Bash
Executable File

#!/bin/bash -e
dir=/var/lib/archbuilddest/srcdest
ret=0
age=${1:-90}
while IFS= read -r -d $'\0' file; do
if rm -rf -- "$file"; then
echo "<6>Deleted $file"
else
echo "<3>Error deleting $file"
ret=1
fi
done < <(
find "$dir" -maxdepth 1 -type f -atime +$age -print0
rage=$((age + 1))
while IFS= read -r -d $'\0' folder; do
if [[ -z $(find "$folder" -type f -atime -$rage -print -quit) ]]; then
printf '%s\0' "$folder"
fi
done < <(find "$dir" -mindepth 1 -maxdepth 1 -type d -print0)
)
exit $ret
# vim:set sw=2 et: