WIP
This commit is contained in:
parent
3db80ff158
commit
7d030c476b
@ -64,6 +64,7 @@ function main() {
|
||||
#clean DB from old stuff
|
||||
{
|
||||
db_query "DELETE From File WHERE Size=0 OR MD5="" OR MD5 IS NULL;"
|
||||
#find dublicates !
|
||||
}
|
||||
|
||||
#erselle zwei dateilisten
|
||||
@ -163,23 +164,22 @@ function file_add() {
|
||||
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';"))
|
||||
IDs=($(db_query "SELECT ID FROM File WHERE Name='$name' AND Folder='$folder';"))
|
||||
#wenn einmal existiert ...
|
||||
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
|
||||
# undelet files ...
|
||||
db_query "UPDATE File SET TTSync=$TTSYNC_EXIST,TTCheck='$DATE',Size='$SIZE' WHERE AND TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';"
|
||||
|
||||
#same path wrong md5
|
||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE TTSync!='$TTSYNC_REMOTE' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';"
|
||||
|
||||
#if something MVs ...
|
||||
db_query "UPDATE File SET TTCheck='$DATE',Name='$name',Folder='$folder',TTSync='$TTSYNC_EXIST' WHERE AND MD5='$MD5' AND Size='$SIZE' AND Name!='$name' AND Folder!='$folder';"
|
||||
|
||||
else
|
||||
db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"
|
||||
fi
|
||||
|
||||
#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