error corections

This commit is contained in:
6543 2019-05-11 02:25:21 +02:00
parent eb0354cf87
commit f82a1a90df

View File

@ -85,7 +85,7 @@ function main() {
if [ "0" == "$SIZE_new" ]; then
#file exist but empty
#rm "$FILE" <- secure? 2check
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE ID=$ID;"
else
#recalc md5 ... + check
#update DB
@ -93,18 +93,18 @@ function main() {
MD5=$(db_query "SELECT MD5 FROM File WHERE ID=$ID;")

if [ "$MD5" == "$MD5_new" ]; then
db_query "UPDATE File SET Size=$SIZE_new,TTCheck=$DATE WHERE ID=$ID;"
db_query "UPDATE File SET Size=$SIZE_new,TTCheck='$DATE' WHERE ID=$ID;"
else
#new file/file changed!
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
file_add "$(db_query "SELECT CONCAT(Folder, '/', Name) FROM File WHERE ID=$ID;")"
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE ID=$ID;"
file_add "$(db_query "SELECT CONCAT(Folder, '/', Name) FROM File WHERE ID=$ID;")" "$MD5_new"
fi

fi
}
else
# file dont exist
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck=$DATE WHERE ID=$ID;"
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE ID=$ID;"
fi

done
@ -146,15 +146,16 @@ function file_size() {
fi
}

# file_add [rel.path] (md5)
function file_add() {
echo 2DO
local relrevpath="$(echo $1 | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g")" #last statement set ' as '' so it wont have an evect in the sql statement
local name="$(echo $relrevpath | cut -d '/' -f 1 | rev)"
local folder="$(echo $relrevpath | cut -d '/' -f 2- | rev)"
local FILE="$moviedir/$(echo $relrevpath | rev)"
local MD5="$2"
local relrevpath="$(echo "$1" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g")" #last statement set ' as '' so it wont have an evect in the sql statement
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
local MD5_new=$(md5sum "$FILE" | cut -c -32)
local SIZE_new="$(file_size "$FILE")"
[ -z "$MD5" ] && MD5="$(md5sum "$FILE" | cut -c -32)"
local SIZE="$(file_size "$FILE")"

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