use pv for large files
This commit is contained in:
@@ -27,6 +27,7 @@ for ((i=1; i<=${#@}; i++)) {
|
|||||||
if [[ ${#paths[@]} -eq 0 ]]; then
|
if [[ ${#paths[@]} -eq 0 ]]; then
|
||||||
paths+=(".")
|
paths+=(".")
|
||||||
fi
|
fi
|
||||||
|
which pv &>/dev/null && PVBIN=$( which pv )
|
||||||
set -e
|
set -e
|
||||||
echo "Updating: $list_name"
|
echo "Updating: $list_name"
|
||||||
test -f "$list_name" || touch "$list_name"
|
test -f "$list_name" || touch "$list_name"
|
||||||
@@ -45,10 +46,17 @@ _update() {
|
|||||||
fi
|
fi
|
||||||
if test -f "$1"; then
|
if test -f "$1"; then
|
||||||
if awk '{ print substr($0,35) }' "$list_name" | grep -qFx "$1"; then
|
if awk '{ print substr($0,35) }' "$list_name" | grep -qFx "$1"; then
|
||||||
echo "$1: exist"
|
echo "Exists: $1"
|
||||||
|
else
|
||||||
|
echo "New: $1"
|
||||||
|
size=$( stat -c %s "$1" )
|
||||||
|
if [[ $size -gt 100000000 ]] && [[ -n "$PVBIN" ]]; then
|
||||||
|
# Use pv is size > 100MB
|
||||||
|
sum=$( $PVBIN "$1" | md5sum | awk '{ print $1 }' )
|
||||||
|
printf "%s %s\n" "$sum" "$1" >> "$list_name"
|
||||||
else
|
else
|
||||||
echo "$1: new"
|
|
||||||
md5sum "$1" >> "$list_name"
|
md5sum "$1" >> "$list_name"
|
||||||
|
fi
|
||||||
updates_done=1
|
updates_done=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user