From 1d8ef909681b2bb37e5ecd4284b0bdcf825e56ec Mon Sep 17 00:00:00 2001 From: ScriptFanix Date: Mon, 10 Nov 2025 00:53:37 +0100 Subject: [PATCH] Revert "Merge branch '27-script-is-uselessly-verbose' into 'dev'" This reverts merge request !34 --- atom | 79 ++++++++++++++++++++++++---------------------- lib/copy/action | 36 ++++++--------------- lib/files/getFiles | 5 +-- lib/tags/update | 4 +-- 4 files changed, 55 insertions(+), 69 deletions(-) diff --git a/atom b/atom index d7dcd5c..44bd4f9 100755 --- a/atom +++ b/atom @@ -231,8 +231,8 @@ do done done -unset deleted -unset removed +deleted=0 +removed=0 echo 'BEGIN TRANSACTION;' >&3 for id in ${!removefile[@]} do @@ -256,7 +256,7 @@ do done echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' -echo -n "${deleted+$deleted files deleted${removed:+, }}${removed:+$removed removed from database}" +echo -n "Suppressed $deleted files, $removed removed from database" (( cron )) || echo -ne "\033[K" echo unset removecount deleted removed removefile @@ -272,8 +272,7 @@ do Update destination_files last_change 0 \ <<<"destination_id = $forcedestid" else - echo "Full rebuild of destination $forcedest was requested," \ - "but it does not exist!" >&2 + echo "Destination $forcedest does not exist!" >&2 fi done @@ -442,7 +441,7 @@ do decodefiles+=("$line::AtOM:SQL:Sep::") read -u4 line done -(( cron )) || echo -n $'Creating tasks...\033[K' +(( cron )) || echo -n 'Creating tasks... ' (( textunidecodeneeded )) && ascii @@ -548,11 +547,8 @@ do tmpfile done echo 'COMMIT;' >&3 -(( cron )) || echo -n $'\r\033[K' -(( count )) \ -&& echo "Created $count tasks for $filecount files \ - ${togo:+($togo left) } \ - ${copies:+($copies immediate copies)}" +(( cron )) || echo -n $'\r' +echo "Created ${count:-0} tasks for $filecount files ${togo:+($togo left) }(${copies:-0} immediate copies)" # remove perl unicode to ascii coprocess (( textunidecodeneeded )) && eval exec "${toascii[1]}>&-" @@ -567,7 +563,7 @@ remaining=$taskcount failed=0 echo 'BEGIN TRANSACTION;' >&3 committime=$EPOCHSECONDS -while (( remaining || ${#workers[@]} )) +while (( (remaining || ${#workers[@]}) && ! quit )) do timestamp=$EPOCHSECONDS if (( $timestamp - committime >= 60 )) @@ -581,10 +577,12 @@ do then concurrency="$fixed_workers" else - if (( timestamp - concurrencychange >= loadinterval )) + if [ -z "$quit" ] \ + && (( ! pause )) \ + && (( timestamp - concurrencychange >= loadinterval )) then - if (( concurrency > 1 || allow_zero_running )) \ - && (( load > maxload && concurrency > 0 )) + if (( concurrency > 1 )) \ + && (( load > maxload )) then concurrencychange=$timestamp (( --concurrency )) @@ -597,11 +595,16 @@ do fi checkworkers cleaner - master + (( pause )) || master if (( ran - failed )) then currenttime=$timestamp - (( runtime = currenttime - starttime )) + if (( pause )) + then + (( runtime = pausestart - starttime - pausedtime )) + else + (( runtime = currenttime - starttime - pausedtime )) + fi avgduration=$(( ( runtime * 1000) / @@ -637,7 +640,11 @@ do fmtprogress="T:%${#taskcount}i/%i (F:%i) %3i%%" fmttime='%2id %2ih%02im%02is (A:%4.1fs/task)' eta="ETA:$( - printf "%(%c)T" "$(( currenttime + secsremaining )) + date -d "${days:-0} days + ${hours:-0} hours + ${minutes:-0} minutes + ${seconds:-0} seconds" \ + +'%d/%m %H:%M:%S' )" (( cron )) || printf \ "\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\ @@ -654,7 +661,7 @@ do ${minutes:-0} \ ${seconds:-0} \ ${avgdsec:-0}.${avgdmsec:-0} - if ! (( concurrency )) + if (( pause )) then if (( active )) then @@ -669,25 +676,22 @@ unset count endtime=$EPOCHSECONDS -(( elapsedseconds = endtime - starttime )) +(( elapsedseconds = endtime - starttime - pausedtime )) (( days = elapsedseconds / ( 24*60*60 ) )) || true -(( days )) || unset days (( hours = ( elapsedseconds - ( days*24*60*60 ) ) / ( 60*60 ) )) || true -(( days && hours )) || unset hours (( minutes = ( elapsedseconds - ( ( days*24 + hours ) *60*60 ) ) / 60 )) || true -(( days && hours && minutes )) || unset minutes (( seconds = elapsedseconds - @@ -695,12 +699,8 @@ endtime=$EPOCHSECONDS )) || true (( cron )) || echo -n $'\r' -(( ran )) \ -&& echo -n "Ran $ran tasks${failed:+, $failed of which failed,} \ - in ${days:+$days days,} \ - ${hours:+$hours hours,} \ - ${minutes:+$minutes minutes and} \ - $seconds seconds." +echo -n "Ran ${ran:=0} tasks, $failed of which failed, in $days" \ + "days, $hours hours, $minutes minutes and $seconds seconds." (( cron )) || echo -en "\033[K" echo if (( failed )) @@ -785,10 +785,17 @@ then echo "${line%%::AtOM:SQL:Sep::*}" line="${line#*::AtOM:SQL:Sep::}" line="${line//::AtOM:SQL:Sep::/ }" - echo $'\t'"${line/+( )$/}"$'\n' + echo $'\t'"${line/+( )$/}" + echo done fi +if [ -n "$quit" ] +then + closeDatabase + exit +fi + for destination in "${!destinationpath[@]}" do echo ' @@ -902,7 +909,7 @@ do "${destinationfat32compat["$destination"]}," \ " ascii=" \ "${destinationascii["$destination"]}" \ - "WHERE id=$destfileid;" \ + "WHERE id=$destfileid;" \ >&3 if (( commit )) then @@ -915,8 +922,7 @@ do (( textunidecodeneeded )) && eval exec "${toascii[1]}>&-" echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' - (( changedcount )) \ - && echo -n "$destination: Renamed $changedcount files" + echo -n "$destination: Renamed ${changedcount:-0} files" (( cron )) || echo -en "\033[K" echo fi @@ -939,7 +945,7 @@ echo ' SELECT "AtOM:NoMoreFiles"; ' >&3 -(( cron )) || echo -n 'Removing obsolete files...'$'\033[K' +(( cron )) || echo -n 'Removing obsolete files... ' lines=() read -u4 line while [[ $line != AtOM:NoMoreFiles ]] @@ -966,12 +972,11 @@ do done echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' -(( count )) \ -&& echo -n "Removed $count obsolete files." +echo -n "Removed ${count:-0} obsolete files." (( cron )) || echo -en "\033[K" echo -echo "Purging empty directories..." +echo "Purging empty directories." for path in "${destinationpath[@]}" do find "$path" -type d -empty -delete diff --git a/lib/copy/action b/lib/copy/action index f4d700d..63e7d75 100644 --- a/lib/copy/action +++ b/lib/copy/action @@ -1,6 +1,6 @@ #!/bin/bash copyFiles_action() { - (( cron )) || echo -n $'Copying files...\033[K' + (( cron )) || echo -n "Copying files... " echo ' SELECT source_files.filename, @@ -79,29 +79,15 @@ copyFiles_action() { fi fi fi - if cp -a --reflink=always \ - "$sourcepath/$sourcefilename" \ - "$destdir" \ - 2>/dev/null \ - || cp -al \ - "$sourcepath/$sourcefilename" \ - "$destdir" \ - 2>/dev/null \ - || cp -a \ - "$sourcepath/$sourcefilename" \ - "$destdir" + if cp -al "$sourcepath/$sourcefilename" "$destdir" 2>/dev/null\ + || cp -a "$sourcepath/$sourcefilename" "$destdir" then Update destination_files \ - filename \ - "$destdir/${sourcefilename##*/}"\ - rename_pattern \ - "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\ - fat32compat \ - ${destinationfat32compat["$destination"]}\ - ascii \ - ${destinationascii["$destination"]}\ - last_change \ - $lastchange \ + filename "$destdir/${sourcefilename##*/}"\ + rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\ + fat32compat ${destinationfat32compat["$destination"]}\ + ascii ${destinationascii["$destination"]}\ + last_change $lastchange \ <<-EOWhere id = $destfileid EOWhere @@ -112,14 +98,12 @@ copyFiles_action() { if (( count )) then (( cron )) || echo -n $'\r' - if (( count )) - then - echo -n "Copied ${done:-0} of $count" \ + echo -n "Copied ${done:-0} of $count" \ "files${postponed+ ($postponed postponed)}." (( cron )) || echo -en "\033[K" echo else - (( cron )) || echo -n $'\r\033[K' + (( cron )) || echo -e "\rNothing to copy.\033[K" fi unset count done } diff --git a/lib/files/getFiles b/lib/files/getFiles index 28077bf..72a21d8 100644 --- a/lib/files/getFiles +++ b/lib/files/getFiles @@ -67,9 +67,6 @@ getFiles() { ) echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' - if (( count )) - then - echo "$count files found${new:+, $new new or changed}." \ - $'\033[K' + echo "${count:-0} files found, ${new:=0} new or changed."$'\033[K' unset count } diff --git a/lib/tags/update b/lib/tags/update index 643bed4..25fef11 100644 --- a/lib/tags/update +++ b/lib/tags/update @@ -206,8 +206,8 @@ echo ' done echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' - (( count )) && echo -n "Read tags from $count files." - (( cron )) || echo -n '\033[K' + echo -n "Read tags from ${count:-0} files." + (( cron )) || echo -ne "\033[K" echo unset count tagfiles }