Compare commits

...

6 Commits

Author SHA1 Message Date
Vincent Riquer
76bad8af0b toys: cleanup 2026-02-15 03:32:54 +01:00
Vincent Riquer
1fe4099350 toys fixes
checkmissing: add missing read -d \0
cleandestinations: use NULL separator in find, use SQL placedholmder
2026-02-15 03:32:18 +01:00
Vincent Riquer
e0c3aea43c decodeSox, decodeMpcdec, decodeOpus: use SQL placeholder 2026-02-15 03:28:32 +01:00
Vincent Riquer
3624e50416 copyFiles_action: use SQL placeholder 2026-02-15 03:26:16 +01:00
Vincent Riquer
36dd9d43dd getFiles, getDestDir, getDestFile: use SQL placeholder 2026-02-15 03:25:19 +01:00
Vincent Riquer
f8bb5377ae SQL: replace LF with placeholde in Select, the other way around in Insert 2026-02-15 03:24:09 +01:00
11 changed files with 19 additions and 17 deletions

View File

@ -91,9 +91,10 @@ copyFiles_action() {
"$sourcepath/$sourcefilename" \
"$destdir"
then
destfilename=${sourcefilename//$'\n'/::AtOM:NewLine:SQL:Inline::}
Update destination_files \
filename \
"$destdir/${sourcefilename##*/}"\
"$destdir/${destfilename##*/}"\
rename_pattern \
"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"\
fat32compat \

View File

@ -26,6 +26,7 @@ Insert() {
insert_values+=$value
;;
*)
value=${value//::AtOM:NewLine:SQL:Inline::/$'\n'}
insert_values+='"'"${value//\"/\"\"}"'"'
;;
esac

View File

@ -19,6 +19,7 @@ Select() {
while read key operator value
do
(( ${#where_statement} )) && where_statement+=( "AND" )
value=${value//::AtOM:NewLine:SQL:Inline::/$'\n'}
where_statement+=( "$key $operator "'"'"${value//\"/\"\"}"'"' )
done
echo "SELECT IFNULL(" \

View File

@ -2,5 +2,5 @@
decodeMpcdec() {
tmpfile="${fileid}mpcdec"
commandline=(${ionice}mpcdec)
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}" "$tempdir/$tmpfile.wav")
}

View File

@ -2,5 +2,5 @@
decodeOpusdec() {
tmpfile="${fileid}opusdec"
commandline=(${ionice}opusdec)
commandline+=("$sourcepath/$filename" "$tempdir/$tmpfile.wav")
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}" "$tempdir/$tmpfile.wav")
}

View File

@ -12,7 +12,7 @@ decodeSox() {
then
commandline+=("$1")
else
commandline+=("$sourcepath/$filename")
commandline+=("$sourcepath/${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}")
fi
if [ -n "${destinationfrequency["$destination"]}" ] \
&& (( ${rate:-0} != ${destinationfrequency["$destination"]} ))

View File

@ -103,4 +103,5 @@ getDestDir() {
mkdir -p "${destinationpath[$destination]}/$destdir"
fi
destdir="${destdir//+(\/)//}"
destdir=${destdir//$'\n'/::AtOM:NewLine:SQL:Inline::}
}

View File

@ -55,6 +55,7 @@ getDestFile() {
destfile="${filename##*/}"
destfile="${destfile%.*}"
fi
destfile=${destfile//$'\n'/::AtOM:NewLine:SQL:Inline::}
if (( ${destinationascii["$destination"]} ))
then
echo "$destfile" >&${toascii[1]}

View File

@ -17,7 +17,7 @@ getFiles() {
compare_time=$time
fi
if ! Select source_files id >/dev/null <<-EOWhere
filename = $filename
filename = ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
mime_type > 0
last_change LIKE $compare_time
size = $size
@ -47,7 +47,7 @@ getFiles() {
mime_type $mimetypeid \
>/dev/null \
<<-EOWhere
filename $filename
filename ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
EOWhere
(( ++new ))
if (( new % 1000 == 0 ))
@ -58,7 +58,7 @@ getFiles() {
fi
else
Update source_files last_seen $scantime <<-EOWhere
filename = $filename
filename = ${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
EOWhere
fi
progressSpin

View File

@ -65,6 +65,7 @@ getConfig
sanityCheck
openDatabase
echo -n "Checking for missing files... "
echo '
SELECT
destination_files.id,
@ -87,12 +88,11 @@ do
destination_names[id]=${rest%%::AtOM:SQL:Sep::*}
rest=${rest#*::AtOM:SQL:Sep::}
files[id]=${rest}
read -u4 line
read -u4 -r -d $'\0' line
done
echo 'BEGIN TRANSACTION;' >&3
echo -n "Checking for missing files... "
for index in "${!files[@]}"
do
destination=${destination_names[index]}

View File

@ -65,25 +65,22 @@ getConfig
sanityCheck
openDatabase
checkwanted() {
Select id <<<"filename = $1"
}
for destination in "${!destinationpath[@]}"
do
echo -ne "\rScanning destination $destination... \033[K"
while read -r filename
while read -r -d $'\0' filename
do
sqlfile=${filename//$'\n'/::AtOM:NewLine:SQL:Inline::}
if ! Select destination_files id \
>/dev/null \
<<<"filename = ${filename#${destinationpath["$destination"]}/}"
<<<"filename = ${sqlfile#${destinationpath["$destination"]}/}"
then
echo -e $'\r'"$filename\033[K"
(( remove )) && rm -f "$filename"
(( remove )) && rm "$filename"
echo -n "Scanning destination $destination... "
fi
progressSpin
done < <(find "${destinationpath["$destination"]}" -type f)
done < <(find "${destinationpath["$destination"]}" -type f -print0)
done
echo -en "\r\033[K"