vereinfache
This commit is contained in:
parent
bf52083d13
commit
88cd69ed7b
@ -163,10 +163,8 @@ function file_add() {
|
|||||||
[ -z "$MD5" ] && MD5="$(md5sum "$FILE" | cut -c -32)"
|
[ -z "$MD5" ] && MD5="$(md5sum "$FILE" | cut -c -32)"
|
||||||
local SIZE="$(file_size "$FILE")"
|
local SIZE="$(file_size "$FILE")"
|
||||||
|
|
||||||
#check if already exist
|
|
||||||
IDs=($(db_query "SELECT ID FROM File WHERE Name='$name' AND Folder='$folder';"))
|
|
||||||
#wenn einmal existiert ...
|
#wenn einmal existiert ...
|
||||||
if [ "${#IDs[@]}" -gt 0 ]; then
|
{
|
||||||
# undelet files ...
|
# undelet files ...
|
||||||
local IDs_undel="$(db_query "SELECT ID FROM File WHERE AND TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';")"
|
local IDs_undel="$(db_query "SELECT ID FROM File WHERE AND TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';")"
|
||||||
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';"
|
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';"
|
||||||
@ -178,20 +176,11 @@ function file_add() {
|
|||||||
#if something MVs ...
|
#if something MVs ...
|
||||||
local IDs_mv="$(db_query "SELECT ID FROM File WHERE AND MD5='$MD5' AND Size='$SIZE' AND Name!='$name' AND Folder!='$folder';")"
|
local IDs_mv="$(db_query "SELECT ID FROM File WHERE AND MD5='$MD5' AND Size='$SIZE' AND Name!='$name' AND Folder!='$folder';")"
|
||||||
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';"
|
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';"
|
||||||
|
}
|
||||||
|
|
||||||
#wenn gelöschte wiederhergestellt oder verschobene dateien entdekt... -> func done
|
#wenn weder gelöschte wiederhergestellt noch verschobene dateien entdekt... -> neuer eintrag
|
||||||
|
[ "$((${#IDs_mv}+${#IDs_undel}))" -gt 0 ] && db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"
|
||||||
|
|
||||||
else
|
|
||||||
db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#db path exist && ttsync=exist/backup && md5 !same -> ttsync=del + new db entry
|
|
||||||
#or new db entry
|
|
||||||
|
|
||||||
#db entry is{
|
|
||||||
# chek if size ->md5 exist -> update path&name (MV)
|
|
||||||
# else complete new entry
|
|
||||||
#}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user