WIP
This commit is contained in:
parent
00de0a03cc
commit
3db80ff158
@ -165,15 +165,20 @@ function file_add() {
|
||||
#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 ... "
|
||||
|
||||
if [ "${#IDs[@]}" -gt 0 ]; then
|
||||
if [ "${#IDs[@]}" == 1 ]; then
|
||||
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]}';"
|
||||
else
|
||||
#wenn merfach vorhanden, einträge löschen
|
||||
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');"
|
||||
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user