ADD DEBUG Const. -> release dont speac
This commit is contained in:
parent
65738dae63
commit
3d3641a3d9
@ -14,6 +14,7 @@
|
|||||||
readonly TTSYNC_REMOTE=2 #file exists remote - not used jet
|
readonly TTSYNC_REMOTE=2 #file exists remote - not used jet
|
||||||
readonly TTSYNC_DEL=3 #local file deleted
|
readonly TTSYNC_DEL=3 #local file deleted
|
||||||
readonly globalconf="/etc/tt/global"
|
readonly globalconf="/etc/tt/global"
|
||||||
|
readonly DEBUG=$TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #get options & args
|
{ #get options & args
|
||||||
@ -76,7 +77,8 @@ function main() {
|
|||||||
#all IDs wich an old check date:
|
#all IDs wich an old check date:
|
||||||
db_query "SELECT ID FROM File Where TTCheck < '$DATE' OR TTCheck IS NULL;" | while read line; do
|
db_query "SELECT ID FROM File Where TTCheck < '$DATE' OR TTCheck IS NULL;" | while read line; do
|
||||||
#for each ID with an old check date ...
|
#for each ID with an old check date ...
|
||||||
ID=$line && echo "Progress ID: $ID"
|
ID=$line
|
||||||
|
[ $DEBUG == $TRUE ] && echo "Progress ID: $ID" >&2
|
||||||
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
|
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
|
||||||
if [ -f "$FILE" ]; then
|
if [ -f "$FILE" ]; then
|
||||||
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
|
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
|
||||||
@ -158,6 +160,7 @@ function file_add() {
|
|||||||
echo "ERROR: file_add: file not exist: $FILE"
|
echo "ERROR: file_add: file not exist: $FILE"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
[ $DEBUG == $TRUE ] && echo "add: $name" >&2
|
||||||
[ -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")"
|
||||||
[ "$SIZE" -le 0 ] && {
|
[ "$SIZE" -le 0 ] && {
|
||||||
@ -169,18 +172,21 @@ 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
|
||||||
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';"
|
||||||
|
|
||||||
#same path wrong md5
|
#same path wrong md5
|
||||||
#local IDs_W5="$(db_query "SELECT ID FROM File WHERE TTSync!='$TTSYNC_REMOTE' AND TTSync!='$TTSYNC_DEL' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';")"
|
[ $DEBUG == $TRUE ] && echo "IDs_W5: $(db_query "SELECT ID FROM File WHERE TTSync!='$TTSYNC_REMOTE' AND TTSync!='$TTSYNC_DEL' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';")" >&2
|
||||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE TTSync!='$TTSYNC_REMOTE' AND TTSync!='$TTSYNC_DEL' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';"
|
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE TTSync!='$TTSYNC_REMOTE' AND TTSync!='$TTSYNC_DEL' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';"
|
||||||
|
|
||||||
#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
|
||||||
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
|
||||||
local IDs_orig="$(db_query "SELECT ID FROM File WHERE MD5='$MD5' AND Name='$name' AND Folder='$folder';")"
|
local IDs_orig="$(db_query "SELECT ID FROM File WHERE MD5='$MD5' AND Name='$name' AND Folder='$folder';")"
|
||||||
|
[ $DEBUG == $TRUE ] && echo "IDs_orig: $IDs_orig" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
#wenn weder gelöschte wiederhergestellt noch verschobene dateien entdekt... -> neuer eintrag
|
#wenn weder gelöschte wiederhergestellt noch verschobene dateien entdekt... -> neuer eintrag
|
||||||
@ -196,6 +202,7 @@ function db_query() {
|
|||||||
args+=" -u$dbuser"
|
args+=" -u$dbuser"
|
||||||
[ -n "$dbpwd" ] && args+=" -p$dbpwd"
|
[ -n "$dbpwd" ] && args+=" -p$dbpwd"
|
||||||
args+=" $dbname"
|
args+=" $dbname"
|
||||||
|
[ $DEBUG == $TRUE ] && echo $@ >&2
|
||||||
echo $@ | mysql $args
|
echo $@ | mysql $args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user