fix: change tasks table schema
replace required with required_by change meaning of field
This commit is contained in:
parent
5f9bd027f3
commit
ba459feb90
2
atom
2
atom
@ -429,7 +429,7 @@ echo '
|
||||
CREATE TEMPORARY TABLE tasks(
|
||||
id INTEGER PRIMARY KEY,
|
||||
requires INTEGER,
|
||||
required INTEGER,
|
||||
required_by INTEGER DEFAULT 0,
|
||||
status INTEGER NOT NULL,
|
||||
key TEXT UNIQUE,
|
||||
rename_pattern TEXT,
|
||||
|
||||
@ -165,6 +165,12 @@ decodeFile() {
|
||||
Select tasks id <<<"key = $tmpfile"
|
||||
)
|
||||
then
|
||||
parent_required=$(
|
||||
Select tasks required_by \
|
||||
<<<"id = $decodetaskid"
|
||||
)
|
||||
Update tasks required_by $((++parent_required)) \
|
||||
<<<"id = $decodetaskid"
|
||||
soxtaskid=$(
|
||||
Insert tasks <<-EOInsert
|
||||
key $tmpfile
|
||||
@ -176,7 +182,6 @@ decodeFile() {
|
||||
done
|
||||
)
|
||||
requires $decodetaskid
|
||||
required $decodetaskid
|
||||
status 0
|
||||
cleanup $cleanup
|
||||
EOInsert
|
||||
|
||||
@ -52,7 +52,6 @@ encodeFile::mp3() {
|
||||
Insert tasks <<-EOInsert
|
||||
key ${fileid}lame$destination
|
||||
requires ${soxtaskid:-$decodetaskid}
|
||||
required ${soxtaskid:-$decodetaskid}
|
||||
fileid $destfileid
|
||||
filename $destdir/$destfile.mp3
|
||||
$(
|
||||
@ -74,6 +73,12 @@ encodeFile::mp3() {
|
||||
ascii ${destinationascii["$destination"]}
|
||||
EOInsert
|
||||
)
|
||||
parent_required=$(
|
||||
Select tasks required_by \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
)
|
||||
Update tasks required_by $((++parent_required)) \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
progressSpin
|
||||
soxtaskid=''
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ encodeFile::opus() {
|
||||
Insert tasks <<-EOInsert
|
||||
key ${fileid}opusenc$destination
|
||||
requires ${soxtaskid:-$decodetaskid}
|
||||
required ${soxtaskid:-$decodetaskid}
|
||||
fileid $destfileid
|
||||
filename $destdir/$destfile.opus
|
||||
$(
|
||||
@ -42,6 +41,12 @@ encodeFile::opus() {
|
||||
ascii ${destinationascii["$destination"]}
|
||||
EOInsert
|
||||
)
|
||||
parent_required=$(
|
||||
Select tasks required_by \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
)
|
||||
Update tasks required_by $((++parent_required)) \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
progressSpin
|
||||
soxtaskid=''
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@ encodeFile::vorbis() {
|
||||
Insert tasks <<-EOInsert
|
||||
key ${fileid}oggenc$destination
|
||||
requires ${soxtaskid:-$decodetaskid}
|
||||
required ${soxtaskid:-$decodetaskid}
|
||||
fileid $destfileid
|
||||
filename $destdir/$destfile.ogg
|
||||
$(
|
||||
@ -38,6 +37,12 @@ encodeFile::vorbis() {
|
||||
ascii ${destinationascii["$destination"]}
|
||||
EOInsert
|
||||
)
|
||||
parent_required=$(
|
||||
Select tasks required_by \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
)
|
||||
Update tasks required_by $((++parent_required)) \
|
||||
<<<"id = ${soxtaskid:-$decodetaskid}"
|
||||
progressSpin
|
||||
soxtaskid=''
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ gettaskinfos() {
|
||||
SELECT
|
||||
id,
|
||||
source_file,
|
||||
required,
|
||||
cleanup,
|
||||
fileid,
|
||||
filename
|
||||
@ -16,8 +15,6 @@ gettaskinfos() {
|
||||
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
||||
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
||||
rest=${rest#*::AtOM:SQL:Sep::}
|
||||
required=${rest%%::AtOM:SQL:Sep::*}
|
||||
rest=${rest#*::AtOM:SQL:Sep::}
|
||||
cleanup=${rest%%::AtOM:SQL:Sep::*}
|
||||
rest=${rest#*::AtOM:SQL:Sep::}
|
||||
destfileid=${rest%%::AtOM:SQL:Sep::*}
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
#!/bin/bash
|
||||
checkworkers() {
|
||||
local \
|
||||
taskid \
|
||||
parent_required \
|
||||
parent_task
|
||||
for key in ${!workers[@]}
|
||||
do
|
||||
if ! kill -0 ${workers[key]} 2>/dev/null
|
||||
@ -14,6 +18,19 @@ checkworkers() {
|
||||
failedtasks+=($taskid)
|
||||
(( ++failed ))
|
||||
fi
|
||||
parent_task=$(
|
||||
Select tasks requires \
|
||||
<<<"id = $taskid"
|
||||
)
|
||||
if (( parent_task ))
|
||||
then
|
||||
parent_required=$(
|
||||
Select tasks required_by \
|
||||
<<<"id = $parent_task"
|
||||
)
|
||||
Update tasks required_by $((--parent_required)) \
|
||||
<<<"id = $parent_task"
|
||||
fi
|
||||
unset workertasks[key]
|
||||
fi
|
||||
done
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
#!/bin/bash
|
||||
cleaner() {
|
||||
local \
|
||||
key \
|
||||
faildepends \
|
||||
taskid \
|
||||
count
|
||||
for key in ${!failedtasks[@]}
|
||||
do
|
||||
taskid=${failedtasks[key]}
|
||||
gettaskinfos $taskid
|
||||
faildepends=$(
|
||||
Select tasks 'COUNT(*)' <<-EOWhere
|
||||
requires = $taskid
|
||||
Select tasks required_by <<-EOWhere
|
||||
id = $taskid
|
||||
EOWhere
|
||||
)
|
||||
(( failed+=faildepends ))
|
||||
(( ran+=faildepends ))
|
||||
Update tasks status 2 <<<"id = $taskid"
|
||||
echo "SELECT COUNT(*)
|
||||
FROM tasks
|
||||
WHERE ( status = 0 OR status = 1 )
|
||||
AND required = $taskid;">&3
|
||||
read -u4 count
|
||||
if (( count == 0 ))
|
||||
then
|
||||
rm -f "$cleanup"
|
||||
fi
|
||||
rm -f "$cleanup"
|
||||
unset failedtasks[key]
|
||||
done
|
||||
for key in ${!finishedtasks[@]}
|
||||
@ -60,11 +57,7 @@ cleaner() {
|
||||
"WHERE id=$destfileid;" \
|
||||
>&3
|
||||
fi
|
||||
echo "SELECT COUNT(*)
|
||||
FROM tasks
|
||||
WHERE ( status = 0 OR status = 1 )
|
||||
AND required = $taskid;">&3
|
||||
read -u4 count
|
||||
count=$(Select tasks required_by <<<"id = $taskid")
|
||||
if (( count == 0 ))
|
||||
then
|
||||
rm -f "$cleanup"
|
||||
|
||||
@ -17,7 +17,6 @@ master() {
|
||||
SELECT
|
||||
id,
|
||||
source_file,
|
||||
required,
|
||||
cmd_arg0,
|
||||
cmd_arg1,
|
||||
cmd_arg2,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user