This commit is contained in:
6543 2019-05-11 02:58:47 +02:00
parent be6ac6673a
commit 00de0a03cc

View File

@ -78,7 +78,6 @@ function main() {
db_query "SELECT ID FROM File Where TTCheck < '$DATE' OR TTCheck IS NULL;" | while read line; do
#for each ID with an old check date ...
ID=$line
TTSync=$(db_query "SELECT TTSync FROM File WHERE ID=$ID;")
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
if [ -f "$FILE" ]; then
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
@ -156,10 +155,25 @@ function file_add() {
local name="$(echo "$relrevpath" | cut -d '/' -f 1 | rev)"
local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)"
local FILE="$moviedir/$(echo "$relrevpath" | rev)"
[ -f "$FILE" ] || return 1 #errer file not exist
[ -f "$FILE" ] || {
echo "ERROR: file_add: file not exist: $FILE"
return 1
}
[ -z "$MD5" ] && MD5="$(md5sum "$FILE" | cut -c -32)"
local SIZE="$(file_size "$FILE")"

#check if already exist
IDs=($(db_query "SELECT ID FROM File WHERE Name='$name' AND Folder='$folder' AND MD5='$MD5';"))
#wenn einmal existiert ...
[ "${#IDs[@]}" == 1 ] && {
[ "$(db_query "SELECT TTSync From File WHERE ID='${IDs[0]}';")" == $TTSYNC_DEL ] && db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE ID='${IDs[0]}';"
db_query "UPDATE File SET TTCheck='$DATE' WHERE ID='${IDs[0]}';"
}
[ "${#IDs[@]}" -gt 1 ] &&
ID=$i
echo "INFO: exists ... "

done
#db path exist && md5 same -> update this entry
#db path exist && ttsync=exist/backup && md5 !same -> ttsync=del + new db entry
#or new db entry