atom: Refactor progress info
This commit is contained in:
parent
1d8ef90968
commit
c5ad92f587
79
atom
79
atom
@ -231,8 +231,8 @@ do
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
deleted=0
|
unset deleted
|
||||||
removed=0
|
unset removed
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for id in ${!removefile[@]}
|
for id in ${!removefile[@]}
|
||||||
do
|
do
|
||||||
@ -256,7 +256,7 @@ do
|
|||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r'
|
||||||
echo -n "Suppressed $deleted files, $removed removed from database"
|
echo -n "${deleted+$deleted files deleted${removed:+, }}${removed:+$removed removed from database}"
|
||||||
(( cron )) || echo -ne "\033[K"
|
(( cron )) || echo -ne "\033[K"
|
||||||
echo
|
echo
|
||||||
unset removecount deleted removed removefile
|
unset removecount deleted removed removefile
|
||||||
@ -272,7 +272,8 @@ do
|
|||||||
Update destination_files last_change 0 \
|
Update destination_files last_change 0 \
|
||||||
<<<"destination_id = $forcedestid"
|
<<<"destination_id = $forcedestid"
|
||||||
else
|
else
|
||||||
echo "Destination $forcedest does not exist!" >&2
|
echo "Full rebuild of destination $forcedest was requested," \
|
||||||
|
"but it does not exist!" >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -441,7 +442,7 @@ do
|
|||||||
decodefiles+=("$line::AtOM:SQL:Sep::")
|
decodefiles+=("$line::AtOM:SQL:Sep::")
|
||||||
read -u4 line
|
read -u4 line
|
||||||
done
|
done
|
||||||
(( cron )) || echo -n 'Creating tasks... '
|
(( cron )) || echo -n $'Creating tasks...\033[K'
|
||||||
|
|
||||||
(( textunidecodeneeded )) && ascii
|
(( textunidecodeneeded )) && ascii
|
||||||
|
|
||||||
@ -547,8 +548,11 @@ do
|
|||||||
tmpfile
|
tmpfile
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r\033[K'
|
||||||
echo "Created ${count:-0} tasks for $filecount files ${togo:+($togo left) }(${copies:-0} immediate copies)"
|
(( count )) \
|
||||||
|
&& echo "Created $count tasks for $filecount files \
|
||||||
|
${togo:+($togo left) } \
|
||||||
|
${copies:+($copies immediate copies)}"
|
||||||
|
|
||||||
# remove perl unicode to ascii coprocess
|
# remove perl unicode to ascii coprocess
|
||||||
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
||||||
@ -563,7 +567,7 @@ remaining=$taskcount
|
|||||||
failed=0
|
failed=0
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
committime=$EPOCHSECONDS
|
committime=$EPOCHSECONDS
|
||||||
while (( (remaining || ${#workers[@]}) && ! quit ))
|
while (( remaining || ${#workers[@]} ))
|
||||||
do
|
do
|
||||||
timestamp=$EPOCHSECONDS
|
timestamp=$EPOCHSECONDS
|
||||||
if (( $timestamp - committime >= 60 ))
|
if (( $timestamp - committime >= 60 ))
|
||||||
@ -577,12 +581,10 @@ do
|
|||||||
then
|
then
|
||||||
concurrency="$fixed_workers"
|
concurrency="$fixed_workers"
|
||||||
else
|
else
|
||||||
if [ -z "$quit" ] \
|
if (( timestamp - concurrencychange >= loadinterval ))
|
||||||
&& (( ! pause )) \
|
|
||||||
&& (( timestamp - concurrencychange >= loadinterval ))
|
|
||||||
then
|
then
|
||||||
if (( concurrency > 1 )) \
|
if (( concurrency > 1 || allow_zero_running )) \
|
||||||
&& (( load > maxload ))
|
&& (( load > maxload && concurrency > 0 ))
|
||||||
then
|
then
|
||||||
concurrencychange=$timestamp
|
concurrencychange=$timestamp
|
||||||
(( --concurrency ))
|
(( --concurrency ))
|
||||||
@ -595,16 +597,11 @@ do
|
|||||||
fi
|
fi
|
||||||
checkworkers
|
checkworkers
|
||||||
cleaner
|
cleaner
|
||||||
(( pause )) || master
|
master
|
||||||
if (( ran - failed ))
|
if (( ran - failed ))
|
||||||
then
|
then
|
||||||
currenttime=$timestamp
|
currenttime=$timestamp
|
||||||
if (( pause ))
|
(( runtime = currenttime - starttime ))
|
||||||
then
|
|
||||||
(( runtime = pausestart - starttime - pausedtime ))
|
|
||||||
else
|
|
||||||
(( runtime = currenttime - starttime - pausedtime ))
|
|
||||||
fi
|
|
||||||
avgduration=$((
|
avgduration=$((
|
||||||
( runtime * 1000)
|
( runtime * 1000)
|
||||||
/
|
/
|
||||||
@ -640,11 +637,7 @@ do
|
|||||||
fmtprogress="T:%${#taskcount}i/%i (F:%i) %3i%%"
|
fmtprogress="T:%${#taskcount}i/%i (F:%i) %3i%%"
|
||||||
fmttime='%2id %2ih%02im%02is (A:%4.1fs/task)'
|
fmttime='%2id %2ih%02im%02is (A:%4.1fs/task)'
|
||||||
eta="ETA:$(
|
eta="ETA:$(
|
||||||
date -d "${days:-0} days
|
printf "%(%c)T" "$(( currenttime + secsremaining ))
|
||||||
${hours:-0} hours
|
|
||||||
${minutes:-0} minutes
|
|
||||||
${seconds:-0} seconds" \
|
|
||||||
+'%d/%m %H:%M:%S'
|
|
||||||
)"
|
)"
|
||||||
(( cron )) || printf \
|
(( cron )) || printf \
|
||||||
"\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\
|
"\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\
|
||||||
@ -661,7 +654,7 @@ do
|
|||||||
${minutes:-0} \
|
${minutes:-0} \
|
||||||
${seconds:-0} \
|
${seconds:-0} \
|
||||||
${avgdsec:-0}.${avgdmsec:-0}
|
${avgdsec:-0}.${avgdmsec:-0}
|
||||||
if (( pause ))
|
if ! (( concurrency ))
|
||||||
then
|
then
|
||||||
if (( active ))
|
if (( active ))
|
||||||
then
|
then
|
||||||
@ -676,22 +669,25 @@ unset count
|
|||||||
|
|
||||||
endtime=$EPOCHSECONDS
|
endtime=$EPOCHSECONDS
|
||||||
|
|
||||||
(( elapsedseconds = endtime - starttime - pausedtime ))
|
(( elapsedseconds = endtime - starttime ))
|
||||||
(( days =
|
(( days =
|
||||||
elapsedseconds
|
elapsedseconds
|
||||||
/
|
/
|
||||||
( 24*60*60 )
|
( 24*60*60 )
|
||||||
)) || true
|
)) || true
|
||||||
|
(( days )) || unset days
|
||||||
(( hours =
|
(( hours =
|
||||||
( elapsedseconds - ( days*24*60*60 ) )
|
( elapsedseconds - ( days*24*60*60 ) )
|
||||||
/
|
/
|
||||||
( 60*60 )
|
( 60*60 )
|
||||||
)) || true
|
)) || true
|
||||||
|
(( days && hours )) || unset hours
|
||||||
(( minutes =
|
(( minutes =
|
||||||
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
|
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
|
||||||
/
|
/
|
||||||
60
|
60
|
||||||
)) || true
|
)) || true
|
||||||
|
(( days && hours && minutes )) || unset minutes
|
||||||
(( seconds =
|
(( seconds =
|
||||||
elapsedseconds
|
elapsedseconds
|
||||||
-
|
-
|
||||||
@ -699,8 +695,12 @@ endtime=$EPOCHSECONDS
|
|||||||
)) || true
|
)) || true
|
||||||
|
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r'
|
||||||
echo -n "Ran ${ran:=0} tasks, $failed of which failed, in $days" \
|
(( ran )) \
|
||||||
"days, $hours hours, $minutes minutes and $seconds seconds."
|
&& echo -n "Ran $ran tasks${failed:+, $failed of which failed,} \
|
||||||
|
in ${days:+$days days,} \
|
||||||
|
${hours:+$hours hours,} \
|
||||||
|
${minutes:+$minutes minutes and} \
|
||||||
|
$seconds seconds."
|
||||||
(( cron )) || echo -en "\033[K"
|
(( cron )) || echo -en "\033[K"
|
||||||
echo
|
echo
|
||||||
if (( failed ))
|
if (( failed ))
|
||||||
@ -785,17 +785,10 @@ then
|
|||||||
echo "${line%%::AtOM:SQL:Sep::*}"
|
echo "${line%%::AtOM:SQL:Sep::*}"
|
||||||
line="${line#*::AtOM:SQL:Sep::}"
|
line="${line#*::AtOM:SQL:Sep::}"
|
||||||
line="${line//::AtOM:SQL:Sep::/ }"
|
line="${line//::AtOM:SQL:Sep::/ }"
|
||||||
echo $'\t'"${line/+( )$/}"
|
echo $'\t'"${line/+( )$/}"$'\n'
|
||||||
echo
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$quit" ]
|
|
||||||
then
|
|
||||||
closeDatabase
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
for destination in "${!destinationpath[@]}"
|
for destination in "${!destinationpath[@]}"
|
||||||
do
|
do
|
||||||
echo '
|
echo '
|
||||||
@ -909,7 +902,7 @@ do
|
|||||||
"${destinationfat32compat["$destination"]}," \
|
"${destinationfat32compat["$destination"]}," \
|
||||||
" ascii=" \
|
" ascii=" \
|
||||||
"${destinationascii["$destination"]}" \
|
"${destinationascii["$destination"]}" \
|
||||||
"WHERE id=$destfileid;" \
|
"WHERE id=$destfileid;" \
|
||||||
>&3
|
>&3
|
||||||
if (( commit ))
|
if (( commit ))
|
||||||
then
|
then
|
||||||
@ -922,7 +915,8 @@ do
|
|||||||
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r'
|
||||||
echo -n "$destination: Renamed ${changedcount:-0} files"
|
(( changedcount )) \
|
||||||
|
&& echo -n "$destination: Renamed $changedcount files"
|
||||||
(( cron )) || echo -en "\033[K"
|
(( cron )) || echo -en "\033[K"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
@ -945,7 +939,7 @@ echo '
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
(( cron )) || echo -n 'Removing obsolete files... '
|
(( cron )) || echo -n 'Removing obsolete files...'$'\033[K'
|
||||||
lines=()
|
lines=()
|
||||||
read -u4 line
|
read -u4 line
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
@ -972,11 +966,12 @@ do
|
|||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r'
|
||||||
echo -n "Removed ${count:-0} obsolete files."
|
(( count )) \
|
||||||
|
&& echo -n "Removed $count obsolete files."
|
||||||
(( cron )) || echo -en "\033[K"
|
(( cron )) || echo -en "\033[K"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Purging empty directories."
|
echo "Purging empty directories..."
|
||||||
for path in "${destinationpath[@]}"
|
for path in "${destinationpath[@]}"
|
||||||
do
|
do
|
||||||
find "$path" -type d -empty -delete
|
find "$path" -type d -empty -delete
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user