diff --git a/atom b/atom index 9fb14f4..19d6110 100755 --- a/atom +++ b/atom @@ -1110,6 +1110,7 @@ unset count tagfiles echo ' CREATE TEMPORARY TABLE tasks( id INTEGER PRIMARY KEY, + unicity_check TEXT SECONDARY KEY, command_line TEXT, requires INTEGER, status INTEGER NOT NULL, @@ -1117,6 +1118,117 @@ echo ' ON DELETE SET NULL );' >&3 +echo ' + SELECT COUNT(DISTINCT source_files.id) + FROM source_files, + destinations, + destination_files, + mime_type_actions + WHERE destination_files.last_change < source_files.last_change + AND destinations.id = destination_files.destination_id + AND mime_type_actions.destination_id = destinations.id + AND mime_type_actions.id = source_files.mime_type + AND source_files.id = destination_files.source_file_id + AND mime_type_actions.action = 1;' >&3 +read -u4 filecount +echo ' + SELECT + source_files.id, + source_files.filename, + destinations.name, + destination_files.id, + tags.rate, + tags.channels + FROM source_files, + destinations, + destination_files, + tags, + mime_type_actions + WHERE destination_files.last_change < source_files.last_change + AND destinations.id = destination_files.destination_id + AND mime_type_actions.destination_id = destinations.id + AND mime_type_actions.id = source_files.mime_type + AND source_files.id = destination_files.source_file_id + AND tags.source_file = source_files.id + AND mime_type_actions.action = 1; + + SELECT "AtOM:NoMoreFiles";' >&3 +read -u4 line +while ! [[ $line = AtOM:NoMoreFiles ]] +do + decodefiles+=("$line") + read -u4 line +done +echo -n 'Creating tasks... ' +echo 'BEGIN TRANSACTION;' >&3 +for line in "${decodefiles[@]}" +do + fileid=${line%%|*} + rest=${line#*|} + filename=${rest%%|*} + rest=${rest#*|} + destination=${rest%%|*} + rest=${rest#*|} + destfileid=${rest%%|*} + rest=${rest#*|} + rate=${rest%%|*} + rest=${rest#*|} + channels=${rest%%|*} + unset garbage + if (( ${destinationnormalize["$destination"]} )) + then + soxoptions_in+=" --norm" + fi + if [ -n "${destinationfrequency["$destination"]}" ] \ + && (( ${rate:-0} != ${destinationfrequency["$destination"]} )) + then + soxoptions_out+=" -r ${destinationfrequency["$destination"]}" + fi + if [ -n "${destinationchannels["$destination"]}" ] \ + && (( ${channels:-0} != ${destinationchannels["$destination"]} )) + then + soxoptions_out+=" -c ${destinationchannels["$destination"]}" + fi + tmpfile="$fileid${soxoptions_in// /}${soxoptions_out// /}" + soxoptions_in+=' --single-threaded' + soxoptions_out+=" --temp \"$tempdir\"" + decodetaskid=$( + InsertIfUnset tasks <<-EOInsert + unicity_check $tmpfile + command_line sox $soxoptions_in "$sourcepath/$filename" $soxoptions_out "$tempdir/$tmpfile.wav" + status 0 + EOInsert + ) + case $(( ++count % 40 )) in + 0) echo -ne '\b|' ;; + 10) echo -ne '\b/' ;; + 20) echo -en '\b-' ;; + 30) echo -ne '\b\\' ;; + *) ;; + esac + if (( count % 1000 == 0 )) + then + echo 'COMMIT;BEGIN TRANSACTION;' >&3 + (( debug )) \ + && echo -e "\bCommitted $count tasks... " + fi + unset \ + channels \ + decodetaskid \ + destfileid \ + destination \ + fileid \ + filename \ + rate \ + rest \ + soxoptions_in \ + soxoptions_out \ + tmpfile +done +echo 'COMMIT;' >&3 +echo -e "\rCreated $count tasks for $filecount files" +unset count + closeDatabase # vim:set ts=8 sw=8: