diff --git a/atom b/atom index a879217..eec547f 100755 --- a/atom +++ b/atom @@ -753,7 +753,7 @@ gettag() { | sed -n "/^${1}=/I{s/^${1}=//I;p;q}" } -getInfosMP3_version='ID3-1' +getInfosMP3_version='ID3-2' tagreaders+=( "$getInfosMP3_version" ) getInfos::MP3() { tagreader="$getInfosMP3_version" @@ -767,9 +767,11 @@ getInfos::MP3() { title=$(gettag title) tracknum=$(gettag tracknumber) year=$(gettag year) - expr='^[0-9]*$' + expr='^\([0-9]*\)$' if [[ $genre =~ $expr ]] then + genre=${genre%)} + genre=${genre#(} genre="${id3genres[$genre]}" fi infos="${infos//: /=}" @@ -1225,7 +1227,7 @@ encodeFile::mp3() { cleanup $tempdir/$tmpfile.wav source_file $fileid status 0 - rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}" + rename_pattern ${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]} EOInsert ) progressSpin @@ -1260,7 +1262,7 @@ encodeFile::vorbis() { cleanup $tempdir/$tmpfile.wav source_file $fileid status 0 - rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}" + rename_pattern ${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]} EOInsert ) progressSpin @@ -1273,11 +1275,11 @@ worker() { while : do echo work - read line - until [[ $line != AtOM:ComFail ]] + read -t 10 line + until [ -n "$line" ] && [[ $line != AtOM:ComFail ]] do echo work - read line + read -t 10 line done if [[ $line == AtOM:Die ]] then @@ -1368,19 +1370,19 @@ worker() { if "${cmd_arg[@]}" >/dev/null then echo "finished $taskid|$sourcefileid|$destfileid|$destfilename" - read line + read -t 10 line until [[ $line == AtOM:OK ]] do echo "finished $taskid|$sourcefileid|$destfileid|$destfilename" - read line + read -t 10 line done else echo "failed $taskid" - read line + read -t 10 line until [[ $line == AtOM:OK ]] do echo "failed $taskid" - read line + read -t 10 line done [ -n "$filename" ] \ && eval rm -f $filename @@ -1389,11 +1391,11 @@ worker() { if [ -n "$cleanup" -a -n "$required" ] then echo "cleanup $required" - read answer + read -t 10 answer until [[ $answer != AtOM:ComFail ]] do echo "cleanup $required" - read answer + read -t 10 answer done if (( answer == 1 )) then @@ -1420,6 +1422,52 @@ master() { if [ -n "$quit" ] then destroyworker $workerid + elif [ -n "${workertasks[workerid]}" ] + then + echo ' + SELECT + id, + source_file, + required, + cmd_arg0, + cmd_arg1, + cmd_arg2, + cmd_arg3, + cmd_arg4, + cmd_arg5, + cmd_arg6, + cmd_arg7, + cmd_arg8, + cmd_arg9, + cmd_arg10, + cmd_arg11, + cmd_arg12, + cmd_arg13, + cmd_arg14, + cmd_arg15, + cmd_arg16, + cmd_arg17, + cmd_arg18, + cmd_arg19, + cmd_arg20, + cmd_arg21, + cmd_arg22, + cmd_arg23, + cmd_arg24, + cmd_arg25, + cmd_arg26, + cmd_arg27, + cmd_arg28, + cmd_arg29, + cleanup, + fileid, + filename + FROM tasks + WHERE + id='${workertasks[workerid]}'; + ' >&3 + read -u4 line + eval echo '"$line" >&'$((100+workerid)) elif (( active < concurrency )) then echo ' @@ -1488,21 +1536,19 @@ master() { (( ++active )) read -u4 line taskid=${line%%|*} + workertasks[workerid]=$taskid Update tasks status 1 <<<"id = $taskid" fi eval echo '"$line" >&'$((100+workerid)) else - dyingworker=${workers[workerid]} - unset workers[workerid] - eval echo AtOM:Die '>&'$((100+workerid)) - wait $dyingworker - eval $((100+workerid))'>&-' - eval $((200+workerid))'<&-' - rm "$tempdir"/worker${workerid}{in,out} + destroyworker $workerid fi ;; 'finished') eval 'echo AtOM:OK >&'$((workerid+100)) + [ -z "${workertasks[workerid]}" ] && continue + (( ++ran )) + unset workertasks[workerid] (( active-- )) || true taskid=${workerquery%%|*} rest="${workerquery#*|}|" @@ -1538,12 +1584,15 @@ master() { ;; 'failed') eval 'echo AtOM:OK >&'$((workerid+100)) + [ -z "${workertasks[workerid]}" ] && continue + unset workertasks[workerid] (( --active )) || true (( ++failed )) + (( ++ran )) taskid=$workerquery faildepends=$( Select tasks 'COUNT(*)' <<-EOWhere - requires = taskid + requires = $taskid EOWhere ) (( failed+=faildepends )) @@ -1609,8 +1658,19 @@ checkworkers() { if ! kill -0 ${workers[key]} 2>/dev/null then destroyworker $key nokill + if [ -n "${workertasks[key]}" ] + then + faildepends=$( + Select tasks 'COUNT(*)' <<-EOWhere + requires = ${workertasks[key]} + EOWhere + ) + (( ++failed )) + (( failed+=faildepends )) + Update tasks status 2 <<<"id = ${workertasks[key]}" + Update tasks status 2 <<<"requires = ${workertasks[key]}" + fi createworker $key - (( ++failed )) fi done } @@ -2132,9 +2192,9 @@ do fi echo -en "\rload: $humanload / $maxload" \ "workers: $active / $concurrency" \ - "done: $(( (taskcount - remaining ) * 100 / taskcount ))%" \ - "- $((taskcount - remaining)) of $taskcount ($failed failed)" \ - "${days}d ${hours}h${minutes}m " + "done: $(( ran * 100 / taskcount ))%" \ + "- ${ran:-0} of $taskcount ($failed failed)" \ + "${days}d ${hours}h${minutes}m\c" done unset count @@ -2162,7 +2222,7 @@ endtime=$(date +%s) ( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 ) )) || true -echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \ +echo -e "\rRan ${ran:=0} tasks, $failed of which failed, in $days" \ "days, $hours hours, $minutes minutes and $seconds seconds." if [ -n "$quit" ]