From 8efe73b0e5e1805da51ed4d5e57e0592e8326e22 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Sat, 8 Nov 2025 19:41:35 +0100 Subject: [PATCH] toys: checkmissing: adapt to new schema --- toys/checkmissing | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/toys/checkmissing b/toys/checkmissing index eabef5f..f747f17 100755 --- a/toys/checkmissing +++ b/toys/checkmissing @@ -62,27 +62,42 @@ getConfig sanityCheck openDatabase -echo 'SELECT id,filename FROM destination_files WHERE filename IS NOT NULL;' >&3 +echo ' + SELECT + destination_files.id, + destinations.name, + destination_files.filename + FROM destinations + INNER JOIN destination_files + ON destinations.id=destination_files.destination_id + WHERE filename IS NOT NULL;' >&3 echo 'SELECT "AtOM:NoMoreFiles";' >&3 -read -u4 filename -until [[ $filename == AtOM:NoMoreFiles ]] +declare -a \ + destination_names \ + files +read -u4 line +until [[ $line == AtOM:NoMoreFiles ]] do - files+=("$filename") - read -u4 filename + id=${line%%::AtOM:SQL:Sep::*} + rest=${line#*::AtOM:SQL:Sep::} + destination_names[id]=${rest%%::AtOM:SQL:Sep::*} + rest=${rest#*::AtOM:SQL:Sep::} + files[id]=${rest} + read -u4 line done echo 'BEGIN TRANSACTION;' >&3 echo -n "Checking for missing files... " -for filename in "${files[@]}" +for index in "${!files[@]}" do - id=${filename%%::AtOM:SQL:Sep::*} - filename=${filename#*::AtOM:SQL:Sep::} + destination=${destination_names[index]} + filename="${destinationpath[$destination]}/${files[index]}" if ! [ -f "$filename" ] then echo -e "\r$filename\033[K" - ((regen))&&Update destination_files last_change 0 <<<"id = $id" + ((regen))&&Update destination_files last_change 0 <<<"id = $index" echo -n "Checking for missing files... " (( missing++ )) fi @@ -91,6 +106,6 @@ done echo 'COMMIT;' >&3 -echo -e "\r${missing:-0} missing files\033[K" +echo -e "\r${missing:-No} missing files\033[K" closeDatabase