should work - first tests are god
This commit is contained in:
parent
b5b5885eb0
commit
65738dae63
@ -55,15 +55,13 @@ function help() {
|
|||||||
## Programm Haupt Ablauf ##
|
## Programm Haupt Ablauf ##
|
||||||
###########################
|
###########################
|
||||||
function main() {
|
function main() {
|
||||||
#cd to moviedir
|
|
||||||
cd "$moviedir"
|
|
||||||
|
|
||||||
#db checks
|
#db checks
|
||||||
[ "$(db_check)" == $FALSE ] && exit 1
|
[ "$(db_check)" == $FALSE ] && exit 1
|
||||||
|
|
||||||
#clean DB from old stuff
|
#clean DB from old stuff
|
||||||
{
|
{
|
||||||
db_query "DELETE From File WHERE Size=0 OR MD5="" OR MD5 IS NULL;"
|
db_query "DELETE From File WHERE Size=0 OR MD5='' OR MD5 IS NULL OR Name='';"
|
||||||
#find dublicates !
|
#find dublicates !
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +76,7 @@ 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
|
ID=$line && echo "Progress ID: $ID"
|
||||||
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;")
|
||||||
@ -152,7 +150,7 @@ 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|^/||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 | 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 name="$(echo "$relrevpath" | cut -d '/' -f 1 | rev)"
|
||||||
local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)"
|
local folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)"
|
||||||
local FILE="$moviedir/$(echo "$relrevpath" | rev)"
|
local FILE="$moviedir/$(echo "$relrevpath" | rev)"
|
||||||
@ -162,6 +160,10 @@ 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")"
|
||||||
|
[ "$SIZE" -le 0 ] && {
|
||||||
|
echo File to smal
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
#wenn einmal existiert ...
|
#wenn einmal existiert ...
|
||||||
{
|
{
|
||||||
@ -170,12 +172,12 @@ function file_add() {
|
|||||||
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 MD5!='$MD5' AND Name='$name' AND Folder='$folder';")"
|
#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';")"
|
||||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' WHERE TTSync!='$TTSYNC_REMOTE' 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' AND Folder!='$folder';")"
|
local IDs_mv="$(db_query "SELECT ID FROM File 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 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 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';")"
|
||||||
|
Loading…
Reference in New Issue
Block a user