clipmenud: Check cache file existence before vacuuming

Fixes #123.
This commit is contained in:
Chris Down 2020-04-03 12:27:46 +01:00
parent e7e8425c3b
commit 2677932c56

View file

@ -195,7 +195,8 @@ while true; do
fi
done
if (( CM_MAX_CLIPS )) && (( "$(wc -l < "$cache_file")" > CM_MAX_CLIPS_THRESH )); then
# The cache file may not exist if this is the first run and data is skipped
if (( CM_MAX_CLIPS )) && [[ -f "$cache_file" ]] && (( "$(wc -l < "$cache_file")" > CM_MAX_CLIPS_THRESH )); then
info "Trimming clip cache to CM_MAX_CLIPS ($CM_MAX_CLIPS)"
trunc_tmp=$(mktemp)
tail -n "$CM_MAX_CLIPS" "$cache_file" | uniq > "$trunc_tmp"