diff --git a/atom b/atom index 671ca4e..b88bc65 100755 --- a/atom +++ b/atom @@ -64,6 +64,7 @@ help() { -c Load configuration file -C Dump configuration and exit -l Override max-load + -f Use exactly child processes -T override load-interval -F Force re-generation of all files in @@ -77,7 +78,7 @@ help() { #parse arguments OPTERR=0 -while getopts ':c:Cl:T:F:B:ShDq' opt +while getopts ':c:Cl:T:F:f:B:ShDq' opt do case $opt in c) @@ -95,6 +96,9 @@ do F) forceall+=("$OPTARG") ;; + f) + fixed_workers="$OPTARG" + ;; B) maxbatch="$OPTARG" ;; @@ -349,6 +353,7 @@ updateMimes removeObsoleteFiles +(( cron )) || echo -n 'Gathering files for cleaning...' echo ' SELECT COUNT(id) FROM destination_files @@ -396,7 +401,7 @@ do then echo 'COMMIT;BEGIN TRANSACTION;' >&3 fi - (( cron )) || echo -en "\rClean obsolete data: $(((deleted+removed)*100/removecount))%" + (( cron )) || echo -en "\rClean obsolete data: $(((deleted+removed)*100/removecount))%\033[K" done echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' @@ -692,23 +697,35 @@ starttime=$concurrencychange taskcount=$count remaining=$taskcount failed=0 +echo 'BEGIN TRANSACTION;' >&3 +committime=$(date +%s) while (( (remaining || ${#workers[@]}) && ! quit )) do + if (( $(date +%s) - committime >= 60 )) + then + echo $'COMMIT;\nBEGIN TRANSACTION;' >&3 + committime=$(date +%s) + fi read humanload garbage < /proc/loadavg load=${humanload%.*} - if [ -z "$quit" ] \ - && (( ! pause )) \ - && (( $(date +%s)-concurrencychange >= loadinterval )) + if (( fixed_workers )) then - if (( concurrency > 1 )) \ - && (( load > maxload )) + concurrency="$fixed_workers" + else + if [ -z "$quit" ] \ + && (( ! pause )) \ + && (( $(date +%s)-concurrencychange >= loadinterval )) then - concurrencychange=$(date +%s) - (( --concurrency )) - elif (( load < maxload )) && (( active > concurrency - 1 )) - then - concurrencychange=$(date +%s) - (( ++concurrency )) + if (( concurrency > 1 )) \ + && (( load > maxload )) + then + concurrencychange=$(date +%s) + (( --concurrency )) + elif (( load < maxload )) && (( active > concurrency - 1 )) + then + concurrencychange=$(date +%s) + (( ++concurrency )) + fi fi fi checkworkers @@ -789,6 +806,7 @@ do fi fi done +echo 'COMMIT;' >&3 unset count endtime=$(date +%s) diff --git a/lib/encode/opus b/lib/encode/opus index 2c25f9a..2994190 100644 --- a/lib/encode/opus +++ b/lib/encode/opus @@ -22,7 +22,7 @@ encodeFile::opus() { requires ${soxtaskid:-$decodetaskid} required ${soxtaskid:-$decodetaskid} fileid $destfileid - filename $destdir/$destfile.ogg + filename $destdir/$destfile.opus $( for key in ${!opusencopts[@]} do diff --git a/lib/files/getFiles b/lib/files/getFiles index 51feaf3..8e9daf5 100644 --- a/lib/files/getFiles +++ b/lib/files/getFiles @@ -3,7 +3,7 @@ getFiles() { scantime=$(date +%s) for prune_expression in "${skippeddirectories[@]}" do - prunes+="-path $sourcepath$prune_expression -prune -o " + prunes+=( -path "$sourcepath$prune_expression" -prune -o ) done (( cron )) || echo -n "Scanning $sourcepath... " # We probably have thousands of files, don't waste time on disk writes @@ -56,10 +56,10 @@ getFiles() { fi progressSpin done < <( - find "$sourcepath" $prunes -type f -printf "%T@ %s %P\n" + find "$sourcepath" "${prunes[@]}" -type f -not -name '.*' -printf "%T@ %s %P\n" ) echo 'COMMIT;' >&3 (( cron )) || echo -n $'\r' - echo "${count:-0} files found, ${new:=0} new or changed." + echo "${count:-0} files found, ${new:=0} new or changed."$'\033[K' unset count } diff --git a/lib/tags/ffmpeg b/lib/tags/ffmpeg index da91fbc..0e75477 100644 --- a/lib/tags/ffmpeg +++ b/lib/tags/ffmpeg @@ -1,5 +1,5 @@ #!/bin/bash -getInfosffmpeg_version='ffmpeg-5' +getInfosffmpeg_version='ffmpeg-6' tagreaders+=( "$getInfosffmpeg_version" ) getInfos::ffmpeg() { tagreader="$getInfosffmpeg_version" @@ -8,7 +8,8 @@ getInfos::ffmpeg() { -i "$sourcepath/$filename" 2>&1 \ |sed ' /^Input/,/.* Audio: /{s/ *: */=/} - s/^[[:space:]]*//' + s/^[[:space:]]*// + s/\0//g' ) local metadata=$( echo -e "$allinfos" \ diff --git a/lib/tools/progressSpin b/lib/tools/progressSpin index 40dbb52..3696ece 100644 --- a/lib/tools/progressSpin +++ b/lib/tools/progressSpin @@ -11,5 +11,15 @@ progressSpin() { 30) echo -n $'\b\\' ;; *) ;; esac + if ! (( count % 100 )) + then + echo -n " $count" + until (( backspace > ${#count} )) + do + (( backspace++ )) + echo -n $'\b' + done + unset backspace + fi fi }