Add clipfsck debug utility
This commit is contained in:
parent
25c7503c6a
commit
773a140b7a
32
clipfsck
Executable file
32
clipfsck
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
: "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
|
||||
|
||||
major_version=5
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
cache_dir=$CM_DIR/clipmenu.$major_version.$USER
|
||||
cache_file_prefix=$cache_dir/line_cache
|
||||
|
||||
declare -A cksums
|
||||
|
||||
while IFS= read -r line; do
|
||||
cksum=$(cksum <<< "$line")
|
||||
cksums["$cksum"]="$line"
|
||||
|
||||
# Are all cache entries represented by a file?
|
||||
cache_file=$cache_dir/$cksum
|
||||
if ! [[ -f $cache_file ]]; then
|
||||
printf 'cache entry without file: %s -> %s\n' "$line" "$cache_file" >&2
|
||||
fi
|
||||
done < <(cat "$cache_file_prefix"_* /dev/null | cut -d' ' -f2-)
|
||||
|
||||
# Are all files represented by a cache entry?
|
||||
for file in "$cache_dir"/[012346789]*; do
|
||||
cksum=${file##*/}
|
||||
line=${cksums["$cksum"]-_missing_}
|
||||
if [[ $line == _missing_ ]]; then
|
||||
printf 'file without cache entry: %s\n' "$file"
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue