This commit is contained in:
6543 2019-05-11 03:20:38 +02:00
parent 00de0a03cc
commit 3db80ff158

View File

@ -165,15 +165,20 @@ function file_add() {
#check if already exist #check if already exist
IDs=($(db_query "SELECT ID FROM File WHERE Name='$name' AND Folder='$folder' AND MD5='$MD5';")) IDs=($(db_query "SELECT ID FROM File WHERE Name='$name' AND Folder='$folder' AND MD5='$MD5';"))
#wenn einmal existiert ... #wenn einmal existiert ...
[ "${#IDs[@]}" == 1 ] && { if [ "${#IDs[@]}" -gt 0 ]; then
[ "$(db_query "SELECT TTSync From File WHERE ID='${IDs[0]}';")" == $TTSYNC_DEL ] && db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE ID='${IDs[0]}';" if [ "${#IDs[@]}" == 1 ]; then
db_query "UPDATE File SET TTCheck='$DATE' WHERE ID='${IDs[0]}';" db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE ID='${IDs[0]}' AND TTSync='$TTSYNC_DEL';"
} db_query "UPDATE File SET TTCheck='$DATE',Size='$SIZE' WHERE ID='${IDs[0]}';"
[ "${#IDs[@]}" -gt 1 ] && else
ID=$i #wenn merfach vorhanden, einträge löschen
echo "INFO: exists ... " for i in ${IDs[@]}; do
db_query "DELETE FROM File WHERE ID='$i';"
done
db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"
fi
else
db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"


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