atom: use NULL in reads from db

This commit is contained in:
Vincent Riquer 2025-11-10 15:02:24 +01:00
parent 0f259c6b3f
commit b4d65f15aa

24
atom
View File

@ -202,7 +202,7 @@ echo '
FROM destination_files
WHERE source_file_id is NULL;' >&3
read -u4 removecount
read -u4 -d$'\0' removecount
until (( ${#removefile[@]} == removecount ))
do
echo '
@ -219,7 +219,7 @@ do
SELECT "AtOM:NoMoreFiles";
' >&3
read -u4 line
read -u4 -d$'\0' line
until [[ $line == AtOM:NoMoreFiles ]]
do
removeFileId=${line%%::AtOM:SQL:Sep::*}
@ -227,7 +227,7 @@ do
removeFileDestName=${line%%::AtOM:SQL:Sep::*}
rest=${line#*::AtOM:SQL:Sep::}
removefile[$removeFileId]="${destinationpath["$removeFileDestName"]}/${rest%%::AtOM:SQL:Sep::*}"
read -u4 line
read -u4 -d$'\0' line
done
done
@ -387,7 +387,7 @@ echo '
<> CAST(source_files.last_change AS TEXT)
AND mime_type_actions.destination_id = destinations.id
AND mime_type_actions.action = 1;' >&3
read -u4 filecount
read -u4 -d$'\0' filecount
if [ -n "$maxbatch" ] && (( maxbatch < filecount ))
then
(( togo = filecount - maxbatch ))
@ -436,11 +436,11 @@ echo '
(( maxbatch )) && echo "LIMIT $maxbatch" >&3
echo ';
SELECT "AtOM:NoMoreFiles";' >&3
read -u4 line
read -u4 -d$'\0' line
while ! [[ $line = AtOM:NoMoreFiles ]]
do
decodefiles+=("$line::AtOM:SQL:Sep::")
read -u4 line
read -u4 -d$'\0' line
done
(( cron )) || echo -n $'Creating tasks...\033[K'
@ -776,11 +776,11 @@ then
WHERE tasks.status = 2;
SELECT "AtOM:NoMoreFiles";' >&3
read -u4 line
read -u4 -d$'\0' line
while ! [[ $line = AtOM:NoMoreFiles ]]
do
failedtasks+=("$line")
read -u4 line
read -u4 -d$'\0' line
done
for line in "${failedtasks[@]}"
do
@ -836,11 +836,11 @@ do
SELECT "AtOM:NoMoreFiles";
' >&3
read -u4 line
read -u4 -d$'\0' line
while [[ $line != AtOM:NoMoreFiles ]]
do
renamefiles+=("$line")
read -u4 line
read -u4 -d$'\0' line
done
if (( ${#renamefiles[@]} ))
then
@ -943,11 +943,11 @@ echo '
(( cron )) || echo -n 'Removing obsolete files...'$'\033[K'
lines=()
read -u4 line
read -u4 -d$'\0' line
while [[ $line != AtOM:NoMoreFiles ]]
do
lines+=("$line")
read -u4 line
read -u4 -d$'\0' line
done
echo 'BEGIN TRANSACTION;' >&3
for line in "${lines[@]}"