Compare commits
7 Commits
f3fb58bb7a
...
07022abb46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07022abb46 | ||
|
|
c20433f3b5 | ||
|
|
bfad061264 | ||
|
|
72f0c1aed8 | ||
|
|
c4f92ef3ad | ||
|
|
220a654c51 | ||
|
|
0d2f9a500c |
@ -1,3 +1,12 @@
|
|||||||
|
# 1.0.6
|
||||||
|
### BUGS
|
||||||
|
* Support for newline character in filenames
|
||||||
|
* Fix obsolete files deletion
|
||||||
|
|
||||||
|
### BUGS (Minor)
|
||||||
|
* Fix timing information
|
||||||
|
* Fix level 3+ debug levels (hanging waiting for child processes)
|
||||||
|
|
||||||
# 1.0.5
|
# 1.0.5
|
||||||
### BUGS (Minor)
|
### BUGS (Minor)
|
||||||
* `toys/createindex`: handle empty channel count, bitdepth and sampling rate cleanly
|
* `toys/createindex`: handle empty channel count, bitdepth and sampling rate cleanly
|
||||||
|
|||||||
45
atom
45
atom
@ -202,7 +202,7 @@ echo '
|
|||||||
FROM destination_files
|
FROM destination_files
|
||||||
WHERE source_file_id is NULL;' >&3
|
WHERE source_file_id is NULL;' >&3
|
||||||
|
|
||||||
read -u4 removecount
|
read -u4 -r -d $'\0' removecount
|
||||||
until (( ${#removefile[@]} == removecount ))
|
until (( ${#removefile[@]} == removecount ))
|
||||||
do
|
do
|
||||||
echo '
|
echo '
|
||||||
@ -219,15 +219,15 @@ do
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
removeFileId=${line%%::AtOM:SQL:Sep::*}
|
removeFileId=${line%%::AtOM:SQL:Sep::*}
|
||||||
rest=${line#*::AtOM:SQL:Sep::}
|
rest=${line#*::AtOM:SQL:Sep::}
|
||||||
removeFileDestName=${line%%::AtOM:SQL:Sep::*}
|
removeFileDestName=${rest%%::AtOM:SQL:Sep::*}
|
||||||
rest=${line#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
removefile[$removeFileId]="${destinationpath["$removeFileDestName"]}/${rest%%::AtOM:SQL:Sep::*}"
|
removefile[$removeFileId]="${destinationpath["$removeFileDestName"]}/${rest%%::AtOM:SQL:Sep::*}"
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ do
|
|||||||
filename=${removefile[id]}
|
filename=${removefile[id]}
|
||||||
if [ -n "$filename" ]
|
if [ -n "$filename" ]
|
||||||
then
|
then
|
||||||
if rm -f "$filename"
|
if rm "$filename"
|
||||||
then
|
then
|
||||||
Delete destination_files <<<"id = $id"
|
Delete destination_files <<<"id = $id"
|
||||||
(( ++deleted ))
|
(( ++deleted ))
|
||||||
@ -387,7 +387,7 @@ echo '
|
|||||||
<> CAST(source_files.last_change AS TEXT)
|
<> CAST(source_files.last_change AS TEXT)
|
||||||
AND mime_type_actions.destination_id = destinations.id
|
AND mime_type_actions.destination_id = destinations.id
|
||||||
AND mime_type_actions.action = 1;' >&3
|
AND mime_type_actions.action = 1;' >&3
|
||||||
read -u4 filecount
|
read -u4 -r -d $'\0' filecount
|
||||||
if [ -n "$maxbatch" ] && (( maxbatch < filecount ))
|
if [ -n "$maxbatch" ] && (( maxbatch < filecount ))
|
||||||
then
|
then
|
||||||
(( togo = filecount - maxbatch ))
|
(( togo = filecount - maxbatch ))
|
||||||
@ -436,11 +436,11 @@ echo '
|
|||||||
(( maxbatch )) && echo "LIMIT $maxbatch" >&3
|
(( maxbatch )) && echo "LIMIT $maxbatch" >&3
|
||||||
echo ';
|
echo ';
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
decodefiles+=("$line::AtOM:SQL:Sep::")
|
decodefiles+=("$line::AtOM:SQL:Sep::")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
(( cron )) || echo -n $'Creating tasks...\033[K'
|
(( cron )) || echo -n $'Creating tasks...\033[K'
|
||||||
|
|
||||||
@ -550,9 +550,9 @@ done
|
|||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r\033[K'
|
(( cron )) || echo -n $'\r\033[K'
|
||||||
(( count )) \
|
(( count )) \
|
||||||
&& echo "Created $count tasks for $filecount files \
|
&& echo "Created $count tasks for $filecount files" \
|
||||||
${togo:+($togo left) } \
|
"${togo:+($togo left) }" \
|
||||||
${copies:+($copies immediate copies)}"
|
"${copies:+($copies immediate copies)}"
|
||||||
|
|
||||||
# remove perl unicode to ascii coprocess
|
# remove perl unicode to ascii coprocess
|
||||||
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
(( textunidecodeneeded )) && eval exec "${toascii[1]}>&-"
|
||||||
@ -675,20 +675,17 @@ endtime=$EPOCHSECONDS
|
|||||||
elapsedseconds
|
elapsedseconds
|
||||||
/
|
/
|
||||||
( 24*60*60 )
|
( 24*60*60 )
|
||||||
)) || true
|
)) || unset days
|
||||||
(( days )) || unset days
|
|
||||||
(( hours =
|
(( hours =
|
||||||
( elapsedseconds - ( days*24*60*60 ) )
|
( elapsedseconds - ( days*24*60*60 ) )
|
||||||
/
|
/
|
||||||
( 60*60 )
|
( 60*60 )
|
||||||
)) || true
|
)) || (( days )) || unset hours
|
||||||
(( days && hours )) || unset hours
|
|
||||||
(( minutes =
|
(( minutes =
|
||||||
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
|
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
|
||||||
/
|
/
|
||||||
60
|
60
|
||||||
)) || true
|
)) || (( days || hours )) || unset minutes
|
||||||
(( days && hours && minutes )) || unset minutes
|
|
||||||
(( seconds =
|
(( seconds =
|
||||||
elapsedseconds
|
elapsedseconds
|
||||||
-
|
-
|
||||||
@ -776,11 +773,11 @@ then
|
|||||||
WHERE tasks.status = 2;
|
WHERE tasks.status = 2;
|
||||||
|
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
failedtasks+=("$line")
|
failedtasks+=("$line")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
for line in "${failedtasks[@]}"
|
for line in "${failedtasks[@]}"
|
||||||
do
|
do
|
||||||
@ -836,11 +833,11 @@ do
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
renamefiles+=("$line")
|
renamefiles+=("$line")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
if (( ${#renamefiles[@]} ))
|
if (( ${#renamefiles[@]} ))
|
||||||
then
|
then
|
||||||
@ -943,11 +940,11 @@ echo '
|
|||||||
|
|
||||||
(( cron )) || echo -n 'Removing obsolete files...'$'\033[K'
|
(( cron )) || echo -n 'Removing obsolete files...'$'\033[K'
|
||||||
lines=()
|
lines=()
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
lines+=("$line")
|
lines+=("$line")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for line in "${lines[@]}"
|
for line in "${lines[@]}"
|
||||||
|
|||||||
@ -22,11 +22,11 @@ copyFiles_action() {
|
|||||||
AND mime_type_actions.action = 2;
|
AND mime_type_actions.action = 2;
|
||||||
|
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
copyfiles+=("$line")
|
copyfiles+=("$line")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
|
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
@ -91,9 +91,10 @@ copyFiles_action() {
|
|||||||
"$sourcepath/$sourcefilename" \
|
"$sourcepath/$sourcefilename" \
|
||||||
"$destdir"
|
"$destdir"
|
||||||
then
|
then
|
||||||
|
destfilename=${sourcefilename//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
Update destination_files \
|
Update destination_files \
|
||||||
filename \
|
filename \
|
||||||
"$destdir/${sourcefilename##*/}"\
|
"$destdir/${destfilename##*/}"\
|
||||||
rename_pattern \
|
rename_pattern \
|
||||||
"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
|
"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
|
||||||
fat32compat \
|
fat32compat \
|
||||||
|
|||||||
@ -21,7 +21,7 @@ guessPath() {
|
|||||||
LIMIT 1
|
LIMIT 1
|
||||||
),"0.0");
|
),"0.0");
|
||||||
'>&3
|
'>&3
|
||||||
read -u4 timestamp
|
read -u4 -r -d $'\0' timestamp
|
||||||
if (( ${timestamp/./} == 0 ))
|
if (( ${timestamp/./} == 0 ))
|
||||||
then
|
then
|
||||||
return 2
|
return 2
|
||||||
@ -46,7 +46,7 @@ guessPath() {
|
|||||||
LIMIT 1
|
LIMIT 1
|
||||||
),"AtOM:NotFound");
|
),"AtOM:NotFound");
|
||||||
'>&3
|
'>&3
|
||||||
read -u4 filename
|
read -u4 -r -d $'\0' filename
|
||||||
if [[ $filename != AtOM:NotFound ]]
|
if [[ $filename != AtOM:NotFound ]]
|
||||||
then
|
then
|
||||||
echo "${filename%/*}"
|
echo "${filename%/*}"
|
||||||
|
|||||||
@ -26,6 +26,7 @@ Insert() {
|
|||||||
insert_values+=$value
|
insert_values+=$value
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
value=${value//::AtOM:NewLine:SQL:Inline::/$'\n'}
|
||||||
insert_values+='"'"${value//\"/\"\"}"'"'
|
insert_values+='"'"${value//\"/\"\"}"'"'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -36,7 +37,7 @@ Insert() {
|
|||||||
"( $insert_values );" >&3
|
"( $insert_values );" >&3
|
||||||
(( no_id )) || {
|
(( no_id )) || {
|
||||||
echo 'SELECT LAST_INSERT_ROWID();' >&3
|
echo 'SELECT LAST_INSERT_ROWID();' >&3
|
||||||
read -u 4 results
|
read -u4 -r -d $'\0' results
|
||||||
echo "$results"
|
echo "$results"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ Select() {
|
|||||||
while read key operator value
|
while read key operator value
|
||||||
do
|
do
|
||||||
(( ${#where_statement} )) && where_statement+=( "AND" )
|
(( ${#where_statement} )) && where_statement+=( "AND" )
|
||||||
|
value=${value//::AtOM:NewLine:SQL:Inline::/$'\n'}
|
||||||
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
|
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
|
||||||
done
|
done
|
||||||
echo "SELECT IFNULL(" \
|
echo "SELECT IFNULL(" \
|
||||||
@ -26,7 +27,7 @@ Select() {
|
|||||||
"WHERE ${where_statement[@]})" \
|
"WHERE ${where_statement[@]})" \
|
||||||
",'SQL::Select:not found'" \
|
",'SQL::Select:not found'" \
|
||||||
");" >&3
|
");" >&3
|
||||||
read -u 4 results
|
read -u 4 -r -d $'\0' results
|
||||||
if ! [[ $results == "SQL::Select:not found" ]]
|
if ! [[ $results == "SQL::Select:not found" ]]
|
||||||
then
|
then
|
||||||
echo "$results"
|
echo "$results"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
currentdbversion=7
|
currentdbversion=8
|
||||||
checkDatabaseVersion() {
|
checkDatabaseVersion() {
|
||||||
local dbversion
|
local dbversion
|
||||||
if dbversion=$(Select atom version <<<"\"1\" = 1")
|
if dbversion=$(Select atom version <<<"\"1\" = 1")
|
||||||
@ -15,9 +15,9 @@ checkDatabaseVersion() {
|
|||||||
dbversion=$(Select atom version <<<"\"1\" = 1")
|
dbversion=$(Select atom version <<<"\"1\" = 1")
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Database schema version $dbversion is higher than
|
echo "Database schema version $dbversion is" \
|
||||||
that of this version of AtOM
|
"higher thanthat of this version of" \
|
||||||
($currentdbversion). Bailing out." >&2
|
"AtOM ($currentdbversion). Bailing out." >&2
|
||||||
exit $EDBVERSION
|
exit $EDBVERSION
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|||||||
@ -3,7 +3,8 @@ closeDatabase() {
|
|||||||
echo 'vacuum;' >&3
|
echo 'vacuum;' >&3
|
||||||
echo .quit >&3
|
echo .quit >&3
|
||||||
(( debug )) && echo -n "Waiting for SQLite to terminate... "
|
(( debug )) && echo -n "Waiting for SQLite to terminate... "
|
||||||
wait
|
(( debug > 2 )) && exec 5>&-
|
||||||
|
wait $db_pid
|
||||||
(( debug )) && echo OK
|
(( debug )) && echo OK
|
||||||
exec 3>&-
|
exec 3>&-
|
||||||
exec 4<&-
|
exec 4<&-
|
||||||
|
|||||||
@ -1,14 +1,22 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
openDatabase() {
|
openDatabase() {
|
||||||
|
local \
|
||||||
|
populate_db
|
||||||
|
|
||||||
[[ -f "$database" ]] || populate_db=1
|
[[ -f "$database" ]] || populate_db=1
|
||||||
rm -f "$tempdir"/sqlite.{in,out}
|
rm -f "$tempdir"/sqlite.{in,out}
|
||||||
mkfifo "$tempdir"/sqlite.{in,out}
|
mkfifo "$tempdir"/sqlite.{in,out}
|
||||||
sqlite3 -bail "$database" \
|
stdbuf -o0 sqlite3 -bail \
|
||||||
|
-newline $'::AtOM:SQL:EOL::\n' \
|
||||||
|
"$database" \
|
||||||
< "$tempdir/sqlite.in" \
|
< "$tempdir/sqlite.in" \
|
||||||
|
| stdbuf -o0 \
|
||||||
|
sed 's/::AtOM:SQL:EOL::/\x0/g;s/\(\x0\)\xA/\1/g' \
|
||||||
> "$tempdir/sqlite.out" &
|
> "$tempdir/sqlite.out" &
|
||||||
|
db_pid=$!
|
||||||
exec 3> "$tempdir"/sqlite.in
|
exec 3> "$tempdir"/sqlite.in
|
||||||
exec 4< "$tempdir"/sqlite.out
|
exec 4< "$tempdir"/sqlite.out
|
||||||
rm "$tempdir"/sqlite.in "$tempdir"/sqlite.out
|
rm "$tempdir"/sqlite.{in,out}
|
||||||
if (( debug > 2 ))
|
if (( debug > 2 ))
|
||||||
then
|
then
|
||||||
exec 5>&3
|
exec 5>&3
|
||||||
@ -20,7 +28,7 @@ openDatabase() {
|
|||||||
echo 'PRAGMA recursive_triggers = ON;' >&3
|
echo 'PRAGMA recursive_triggers = ON;' >&3
|
||||||
echo 'PRAGMA temp_store = 2;' >&3
|
echo 'PRAGMA temp_store = 2;' >&3
|
||||||
echo 'PRAGMA locking_mode = EXCLUSIVE;' >&3
|
echo 'PRAGMA locking_mode = EXCLUSIVE;' >&3
|
||||||
read -u4
|
read -u4 -r -d $'\0'
|
||||||
unset REPLY
|
unset REPLY
|
||||||
checkDatabaseVersion
|
checkDatabaseVersion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,11 +18,11 @@ FROM destination_files;
|
|||||||
|
|
||||||
SELECT "AtOM::NoMoreData";' >&3
|
SELECT "AtOM::NoMoreData";' >&3
|
||||||
|
|
||||||
read -u4 data
|
read -u4 -r -d $'\0' data
|
||||||
while [[ $data != AtOM::NoMoreData ]]
|
while [[ $data != AtOM::NoMoreData ]]
|
||||||
do
|
do
|
||||||
datas+=( "$data" )
|
datas+=( "$data" )
|
||||||
read -u4 data
|
read -u4 -r -d $'\0' data
|
||||||
done
|
done
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for data in "${datas[@]}"
|
for data in "${datas[@]}"
|
||||||
|
|||||||
9
lib/database/upgradedatabase_7_8
Normal file
9
lib/database/upgradedatabase_7_8
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
upgradedatabase_6_7() {
|
||||||
|
echo "Upgrading database to version 8... (backup is $database.bak_v7)"
|
||||||
|
cp "$database" "$database.bak_v7"
|
||||||
|
echo 'Deletion of old files was failing. Users of previous versions (YOU!) are strongly advised to run cleandestinations with the "-r" flag.'
|
||||||
|
read -p "Press Enter to continue..."
|
||||||
|
Update atom version 8 <<<"1 = 1"
|
||||||
|
}
|
||||||
@ -2,5 +2,5 @@
|
|||||||
decodeMpcdec() {
|
decodeMpcdec() {
|
||||||
tmpfile="${fileid}mpcdec"
|
tmpfile="${fileid}mpcdec"
|
||||||
commandline=(${ionice}mpcdec)
|
commandline=(${ionice}mpcdec)
|
||||||
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}" "$tempdir/$tmpfile.wav")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,5 +2,5 @@
|
|||||||
decodeOpusdec() {
|
decodeOpusdec() {
|
||||||
tmpfile="${fileid}opusdec"
|
tmpfile="${fileid}opusdec"
|
||||||
commandline=(${ionice}opusdec)
|
commandline=(${ionice}opusdec)
|
||||||
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}" "$tempdir/$tmpfile.wav")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ decodeSox() {
|
|||||||
then
|
then
|
||||||
commandline+=("$1")
|
commandline+=("$1")
|
||||||
else
|
else
|
||||||
commandline+=("$sourcepath/$filename")
|
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}")
|
||||||
fi
|
fi
|
||||||
if [ -n "${destinationfrequency["$destination"]}" ] \
|
if [ -n "${destinationfrequency["$destination"]}" ] \
|
||||||
&& (( ${rate:-0} != ${destinationfrequency["$destination"]} ))
|
&& (( ${rate:-0} != ${destinationfrequency["$destination"]} ))
|
||||||
|
|||||||
@ -88,6 +88,7 @@ getDestDir() {
|
|||||||
while [[ $part =~ / ]]
|
while [[ $part =~ / ]]
|
||||||
do
|
do
|
||||||
thispart="${part%%/*}"
|
thispart="${part%%/*}"
|
||||||
|
thispart=${thispart//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
if (( ${destinationascii["$destination"]} ))
|
if (( ${destinationascii["$destination"]} ))
|
||||||
then
|
then
|
||||||
echo "$thispart" >&${toascii[1]}
|
echo "$thispart" >&${toascii[1]}
|
||||||
@ -100,7 +101,7 @@ getDestDir() {
|
|||||||
fi
|
fi
|
||||||
if ! [ -d "${destinationpath[$destination]}/$destdir" ]
|
if ! [ -d "${destinationpath[$destination]}/$destdir" ]
|
||||||
then
|
then
|
||||||
mkdir -p "${destinationpath[$destination]}/$destdir"
|
mkdir -p "${destinationpath[$destination]}/${destdir//::AtOM:NewLine:SQL:Inline::/$'\n'}"
|
||||||
fi
|
fi
|
||||||
destdir="${destdir//+(\/)//}"
|
destdir="${destdir//+(\/)//}"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,10 +55,11 @@ getDestFile() {
|
|||||||
destfile="${filename##*/}"
|
destfile="${filename##*/}"
|
||||||
destfile="${destfile%.*}"
|
destfile="${destfile%.*}"
|
||||||
fi
|
fi
|
||||||
|
destfile=$(sanitizeFile "$destfile")
|
||||||
|
destfile=${destfile//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
if (( ${destinationascii["$destination"]} ))
|
if (( ${destinationascii["$destination"]} ))
|
||||||
then
|
then
|
||||||
echo "$destfile" >&${toascii[1]}
|
echo "$destfile" >&${toascii[1]}
|
||||||
read -r -u${toascii[0]} destfile
|
read -r -u${toascii[0]} destfile
|
||||||
fi
|
fi
|
||||||
destfile=$(sanitizeFile "$destfile")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ getFiles() {
|
|||||||
(( cron )) || echo -n "Scanning $sourcepath... "
|
(( cron )) || echo -n "Scanning $sourcepath... "
|
||||||
# We probably have thousands of files, don't waste time on disk writes
|
# We probably have thousands of files, don't waste time on disk writes
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
while read time size filename
|
while read -d $'\0' time size filename
|
||||||
do
|
do
|
||||||
if (( skip_us_timestamp ))
|
if (( skip_us_timestamp ))
|
||||||
then
|
then
|
||||||
@ -17,7 +17,7 @@ getFiles() {
|
|||||||
compare_time=$time
|
compare_time=$time
|
||||||
fi
|
fi
|
||||||
if ! Select source_files id >/dev/null <<-EOWhere
|
if ! Select source_files id >/dev/null <<-EOWhere
|
||||||
filename = $filename
|
filename = ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
mime_type > 0
|
mime_type > 0
|
||||||
last_change LIKE $compare_time
|
last_change LIKE $compare_time
|
||||||
size = $size
|
size = $size
|
||||||
@ -47,7 +47,7 @@ getFiles() {
|
|||||||
mime_type $mimetypeid \
|
mime_type $mimetypeid \
|
||||||
>/dev/null \
|
>/dev/null \
|
||||||
<<-EOWhere
|
<<-EOWhere
|
||||||
filename $filename
|
filename ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
EOWhere
|
EOWhere
|
||||||
(( ++new ))
|
(( ++new ))
|
||||||
if (( new % 1000 == 0 ))
|
if (( new % 1000 == 0 ))
|
||||||
@ -58,12 +58,12 @@ getFiles() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
Update source_files last_seen $scantime <<-EOWhere
|
Update source_files last_seen $scantime <<-EOWhere
|
||||||
filename = $filename
|
filename = ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
EOWhere
|
EOWhere
|
||||||
fi
|
fi
|
||||||
progressSpin
|
progressSpin
|
||||||
done < <(
|
done < <(
|
||||||
find "$sourcepath" "${prunes[@]}" -type f -not -name '.*' -printf "%T@ %s %P\n"
|
find "$sourcepath" "${prunes[@]}" -type f -not -name '.*' -printf "%T@ %s %P\0"
|
||||||
)
|
)
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
(( cron )) || echo -n $'\r'
|
(( cron )) || echo -n $'\r'
|
||||||
|
|||||||
@ -52,12 +52,12 @@ echo '
|
|||||||
;
|
;
|
||||||
|
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
tagfiles+=("$line")
|
tagfiles+=("$line")
|
||||||
(( filecount++ ))
|
(( filecount++ ))
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for line in "${tagfiles[@]}"
|
for line in "${tagfiles[@]}"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ gettaskinfos() {
|
|||||||
FROM tasks
|
FROM tasks
|
||||||
WHERE id='$1';
|
WHERE id='$1';
|
||||||
' >&3
|
' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
taskid=${line%%::AtOM:SQL:Sep::*}
|
taskid=${line%%::AtOM:SQL:Sep::*}
|
||||||
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
||||||
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
createworker() {
|
createworker() {
|
||||||
(( ++active ))
|
(( ++active ))
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
taskid=${line%%::AtOM:SQL:Sep::*}
|
taskid=${line%%::AtOM:SQL:Sep::*}
|
||||||
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
||||||
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
sourcefileid=${rest%%::AtOM:SQL:Sep::*}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ master() {
|
|||||||
WHERE status = 0;
|
WHERE status = 0;
|
||||||
'>&3
|
'>&3
|
||||||
|
|
||||||
read -u4 remaining
|
read -u4 -r -d $'\0' remaining
|
||||||
if (( remaining == 0 ))
|
if (( remaining == 0 ))
|
||||||
then
|
then
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
@ -108,7 +108,7 @@ master() {
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
'>&3
|
'>&3
|
||||||
|
|
||||||
read -u4 ready
|
read -u4 -r -d $'\0' ready
|
||||||
if (( ready > 0 ))
|
if (( ready > 0 ))
|
||||||
then
|
then
|
||||||
createworker
|
createworker
|
||||||
@ -194,7 +194,7 @@ master() {
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
read -u4 ready
|
read -u4 -r -d $'\0' ready
|
||||||
|
|
||||||
if (( active == 0 && ready == 0 ))
|
if (( active == 0 && ready == 0 ))
|
||||||
then
|
then
|
||||||
@ -234,7 +234,7 @@ master() {
|
|||||||
WHERE status = 0;
|
WHERE status = 0;
|
||||||
'>&3
|
'>&3
|
||||||
|
|
||||||
read -u4 remaining
|
read -u4 -r -d $'\0' remaining
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,7 +121,7 @@ getdstfiles() {
|
|||||||
;
|
;
|
||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
'>&3
|
'>&3
|
||||||
while read -u4 line
|
while read -u4 -r -d $'\0' line
|
||||||
do
|
do
|
||||||
if [[ $line == AtOM:NoMoreFiles ]]
|
if [[ $line == AtOM:NoMoreFiles ]]
|
||||||
then
|
then
|
||||||
@ -159,7 +159,7 @@ renameFile() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
while read -u4 line
|
while read -u4 -r -d $'\0' line
|
||||||
do
|
do
|
||||||
if [[ $line == AtOM:NoMoreFiles ]]
|
if [[ $line == AtOM:NoMoreFiles ]]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -65,6 +65,7 @@ getConfig
|
|||||||
sanityCheck
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
|
echo -n "Checking for missing files... "
|
||||||
echo '
|
echo '
|
||||||
SELECT
|
SELECT
|
||||||
destination_files.id,
|
destination_files.id,
|
||||||
@ -79,7 +80,7 @@ echo 'SELECT "AtOM:NoMoreFiles";' >&3
|
|||||||
declare -a \
|
declare -a \
|
||||||
destination_names \
|
destination_names \
|
||||||
files
|
files
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
id=${line%%::AtOM:SQL:Sep::*}
|
id=${line%%::AtOM:SQL:Sep::*}
|
||||||
@ -87,12 +88,11 @@ do
|
|||||||
destination_names[id]=${rest%%::AtOM:SQL:Sep::*}
|
destination_names[id]=${rest%%::AtOM:SQL:Sep::*}
|
||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
files[id]=${rest}
|
files[id]=${rest}
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
|
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
|
|
||||||
echo -n "Checking for missing files... "
|
|
||||||
for index in "${!files[@]}"
|
for index in "${!files[@]}"
|
||||||
do
|
do
|
||||||
destination=${destination_names[index]}
|
destination=${destination_names[index]}
|
||||||
|
|||||||
@ -65,25 +65,22 @@ getConfig
|
|||||||
sanityCheck
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
checkwanted() {
|
|
||||||
Select id <<<"filename = $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
for destination in "${!destinationpath[@]}"
|
for destination in "${!destinationpath[@]}"
|
||||||
do
|
do
|
||||||
echo -ne "\rScanning destination $destination... \033[K"
|
echo -ne "\rScanning destination $destination... \033[K"
|
||||||
while read -r filename
|
while read -r -d $'\0' filename
|
||||||
do
|
do
|
||||||
|
sqlfile=${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
|
||||||
if ! Select destination_files id \
|
if ! Select destination_files id \
|
||||||
>/dev/null \
|
>/dev/null \
|
||||||
<<<"filename = ${filename#${destinationpath["$destination"]}/}"
|
<<<"filename = ${sqlfile#${destinationpath["$destination"]}/}"
|
||||||
then
|
then
|
||||||
echo -e $'\r'"$filename\033[K"
|
echo -e $'\r'"$filename\033[K"
|
||||||
(( remove )) && rm -f "$filename"
|
(( remove )) && rm "$filename"
|
||||||
echo -n "Scanning destination $destination... "
|
echo -n "Scanning destination $destination... "
|
||||||
fi
|
fi
|
||||||
progressSpin
|
progressSpin
|
||||||
done < <(find "${destinationpath["$destination"]}" -type f)
|
done < <(find "${destinationpath["$destination"]}" -type f -print0)
|
||||||
done
|
done
|
||||||
echo -en "\r\033[K"
|
echo -en "\r\033[K"
|
||||||
|
|
||||||
|
|||||||
@ -274,7 +274,7 @@ fi
|
|||||||
echo 'SELECT IFNULL(
|
echo 'SELECT IFNULL(
|
||||||
(SELECT last_seen FROM source_files ORDER BY last_seen DESC LIMIT 1),
|
(SELECT last_seen FROM source_files ORDER BY last_seen DESC LIMIT 1),
|
||||||
0);' >&3
|
0);' >&3
|
||||||
read -u4 lastupdate
|
read -u4 -r -d $'\0' lastupdate
|
||||||
|
|
||||||
if ! [[ "$output" == - ]]
|
if ! [[ "$output" == - ]]
|
||||||
then
|
then
|
||||||
@ -369,11 +369,11 @@ COLLATE NOCASE;
|
|||||||
|
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
files+=("$line")
|
files+=("$line")
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
|
|
||||||
for line in "${files[@]}"
|
for line in "${files[@]}"
|
||||||
@ -675,7 +675,7 @@ echo '
|
|||||||
|
|
||||||
SELECT "AtOM:NoMoreFiles";' >&3
|
SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
artist="${line%%::AtOM:SQL:Sep::*}"
|
artist="${line%%::AtOM:SQL:Sep::*}"
|
||||||
@ -685,7 +685,7 @@ do
|
|||||||
artists+=( "$artist" )
|
artists+=( "$artist" )
|
||||||
maxcountlen=$(( ${#count} > maxcountlen ? ${#count} : maxcountlen ))
|
maxcountlen=$(( ${#count} > maxcountlen ? ${#count} : maxcountlen ))
|
||||||
maxartistlen=$(( ${#artist} > maxartistlen ? ${#artist} : maxartistlen ))
|
maxartistlen=$(( ${#artist} > maxartistlen ? ${#artist} : maxartistlen ))
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
head=$(
|
head=$(
|
||||||
printf "| # | %'${maxcoutlen}s | %-${maxartistlen}s |" \
|
printf "| # | %'${maxcoutlen}s | %-${maxartistlen}s |" \
|
||||||
@ -714,7 +714,7 @@ echo '
|
|||||||
FROM source_files
|
FROM source_files
|
||||||
INNER JOIN mime_types
|
INNER JOIN mime_types
|
||||||
ON source_files.mime_type=mime_types.id;' >&3
|
ON source_files.mime_type=mime_types.id;' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
totalcount="${line%%::AtOM:SQL:Sep::*}"
|
totalcount="${line%%::AtOM:SQL:Sep::*}"
|
||||||
maxcountlen=$(printf "%'i" $totalcount)
|
maxcountlen=$(printf "%'i" $totalcount)
|
||||||
maxcountlen=${#maxcountlen}
|
maxcountlen=${#maxcountlen}
|
||||||
@ -743,7 +743,7 @@ do
|
|||||||
INNER JOIN mime_types
|
INNER JOIN mime_types
|
||||||
ON source_files.mime_type=mime_types.id
|
ON source_files.mime_type=mime_types.id
|
||||||
WHERE mime_text LIKE "'"$format"'";' >&3
|
WHERE mime_text LIKE "'"$format"'";' >&3
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
count="${line%%::AtOM:SQL:Sep::*}"
|
count="${line%%::AtOM:SQL:Sep::*}"
|
||||||
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
||||||
size="${rest%%::AtOM:SQL:Sep::*}"
|
size="${rest%%::AtOM:SQL:Sep::*}"
|
||||||
|
|||||||
@ -131,11 +131,11 @@ echo ') ORDER BY bitrate;' >&3
|
|||||||
|
|
||||||
echo 'SELECT "AtOM:NoMoreFiles";' >&3
|
echo 'SELECT "AtOM:NoMoreFiles";' >&3
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
echo "${line//::AtOM:SQL:Sep::/$'\t'}"
|
echo "${line//::AtOM:SQL:Sep::/$'\t'}"
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
|
|
||||||
closeDatabase
|
closeDatabase
|
||||||
|
|||||||
@ -149,11 +149,11 @@ cat >&3 <<-EOSelect
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
EOSelect
|
EOSelect
|
||||||
|
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
until [[ $line == AtOM:NoMoreFiles ]]
|
until [[ $line == AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
lines+=( "$line" )
|
lines+=( "$line" )
|
||||||
read -u4 line
|
read -u4 -r -d $'\0' line
|
||||||
done
|
done
|
||||||
|
|
||||||
for line in "${lines[@]}"
|
for line in "${lines[@]}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user