Meanfull MSGs + Bugfix for char "'"

This commit is contained in:
6543 2019-05-11 22:42:13 +02:00
parent 58c5f080b2
commit 11dca81397

View File

@ -89,8 +89,7 @@ function main() {
[ "$SIZE" != "$SIZE_new" ] && { [ "$SIZE" != "$SIZE_new" ] && {
echo "FILE CHANGE: $FILE" echo "FILE CHANGE: $FILE"
if [ "0" == "$SIZE_new" ]; then if [ "0" == "$SIZE_new" ]; then
#file exist but empty #file exist but to smal
#rm "$FILE" <- secure? 2check
echo "FILE EMPTY: $FILE" echo "FILE EMPTY: $FILE"
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 else
@ -119,7 +118,6 @@ function main() {


#add new files .... #add new files ....
cat "$list_tmp/new" | while read line; do cat "$list_tmp/new" | while read line; do
echo "FILE ADD: $line"
file_add "$line" file_add "$line"
done done


@ -158,9 +156,9 @@ function file_size() {
# file_add [rel.path] (md5) # file_add [rel.path] (md5)
function file_add() { function file_add() {
local MD5="$2" local MD5="$2"
local relrevpath="$(echo "$1" | sed "s|^$moviedir||g" | 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 relrevpath="$(echo "$1" | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev )"
local name="$(echo "$relrevpath" | cut -d '/' -f 1 | rev)" local name="$(echo "$relrevpath" | cut -d '/' -f 1 | rev | sed "s/'/''/g")" #cahr ' set to '' because of SQL Querys
local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)" local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev | sed "s/'/''/g")" #cahr ' set to '' because of SQL Querys
local FILE="$moviedir/$(echo "$relrevpath" | rev)" local FILE="$moviedir/$(echo "$relrevpath" | rev)"
[ -f "$FILE" ] || { [ -f "$FILE" ] || {
echo "ERROR: file_add: file not exist: $FILE" >&2 echo "ERROR: file_add: file not exist: $FILE" >&2
@ -179,6 +177,7 @@ function file_add() {
# undelet files ... # undelet files ...
local IDs_undel="$(db_query "SELECT ID FROM File WHERE TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';")" local IDs_undel="$(db_query "SELECT ID FROM File WHERE TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';")"
[ $DEBUG == $TRUE ] && echo "IDs_undel: $IDs_undel" >&2 [ $DEBUG == $TRUE ] && echo "IDs_undel: $IDs_undel" >&2
[ -n "$IDs_undel" ] && echo "FILE UNDEL: $FILE"
db_query "UPDATE File SET TTSync=$TTSYNC_EXIST,TTCheck='$DATE',Size='$SIZE' WHERE 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 TTSync='$TTSYNC_DEL' AND MD5='$MD5' AND Name='$name' AND Folder='$folder';"


#same path wrong md5 #same path wrong md5
@ -188,6 +187,7 @@ function file_add() {
#if something MVs ... #if something MVs ...
local IDs_mv="$(db_query "SELECT ID FROM File WHERE MD5='$MD5' AND Size='$SIZE' AND (Name!='$name' OR Folder!='$folder');")" local IDs_mv="$(db_query "SELECT ID FROM File WHERE MD5='$MD5' AND Size='$SIZE' AND (Name!='$name' OR Folder!='$folder');")"
[ $DEBUG == $TRUE ] && echo "IDs_mv: $IDs_mv" >&2 [ $DEBUG == $TRUE ] && echo "IDs_mv: $IDs_mv" >&2
[ -n "$IDs_mv" ] && echo "FILE MV: $(db_query "SELECT ID FROM File WHERE ID=$(echo $IDs_mv | cut -d ' ' -f1);") -> $FILE"
db_query "UPDATE File SET TTCheck='$DATE',Name='$name',Folder='$folder',TTSync='$TTSYNC_EXIST' WHERE MD5='$MD5' AND Size='$SIZE' AND (Name!='$name' OR Folder!='$folder');" db_query "UPDATE File SET TTCheck='$DATE',Name='$name',Folder='$folder',TTSync='$TTSYNC_EXIST' WHERE MD5='$MD5' AND Size='$SIZE' AND (Name!='$name' OR Folder!='$folder');"


#es existiert genau so ein eintrag #es existiert genau so ein eintrag
@ -196,7 +196,10 @@ function file_add() {
} }


#wenn weder gelöschte wiederhergestellt noch verschobene dateien entdekt... -> neuer eintrag #wenn weder gelöschte wiederhergestellt noch verschobene dateien entdekt... -> neuer eintrag
[ "$((${#IDs_mv}+${#IDs_undel}+${#IDs_orig}))" == 0 ] && db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');" [ "$((${#IDs_mv}+${#IDs_undel}+${#IDs_orig}))" == 0 ] && {
echo "FILE ADD: $FILE"
db_query "INSERT INTO File (Name,Folder,MD5,Size,TTSync,TTCheck) VALUES ('$name','$folder','$MD5','$SIZE',$TTSYNC_EXIST,'$DATE');"
}


} }