Meanfull MSGs + Bugfix for char "'"
This commit is contained in:
parent
58c5f080b2
commit
11dca81397
@ -89,8 +89,7 @@ function main() {
|
||||
[ "$SIZE" != "$SIZE_new" ] && {
|
||||
echo "FILE CHANGE: $FILE"
|
||||
if [ "0" == "$SIZE_new" ]; then
|
||||
#file exist but empty
|
||||
#rm "$FILE" <- secure? 2check
|
||||
#file exist but to smal
|
||||
echo "FILE EMPTY: $FILE"
|
||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE ID=$ID;"
|
||||
else
|
||||
@ -119,7 +118,6 @@ function main() {
|
||||
|
||||
#add new files ....
|
||||
cat "$list_tmp/new" | while read line; do
|
||||
echo "FILE ADD: $line"
|
||||
file_add "$line"
|
||||
done
|
||||
|
||||
@ -158,9 +156,9 @@ function file_size() {
|
||||
# file_add [rel.path] (md5)
|
||||
function file_add() {
|
||||
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 name="$(echo "$relrevpath" | cut -d '/' -f 1 | rev)"
|
||||
local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)"
|
||||
local relrevpath="$(echo "$1" | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | 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 | sed "s/'/''/g")" #cahr ' set to '' because of SQL Querys
|
||||
local FILE="$moviedir/$(echo "$relrevpath" | rev)"
|
||||
[ -f "$FILE" ] || {
|
||||
echo "ERROR: file_add: file not exist: $FILE" >&2
|
||||
@ -179,6 +177,7 @@ function file_add() {
|
||||
# undelet files ...
|
||||
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
|
||||
[ -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';"
|
||||
|
||||
#same path wrong md5
|
||||
@ -188,6 +187,7 @@ function file_add() {
|
||||
#if something MVs ...
|
||||
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
|
||||
[ -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');"
|
||||
|
||||
#es existiert genau so ein eintrag
|
||||
@ -196,7 +196,10 @@ function file_add() {
|
||||
}
|
||||
|
||||
#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');"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user