minor fixes

This commit is contained in:
Vincent Riquer 2013-04-03 15:11:14 +02:00
parent 799409aa0c
commit ec9201caa9

112
atom
View File

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