should work - first tests are god
This commit is contained in:
parent
b5b5885eb0
commit
65738dae63
@ -19,11 +19,11 @@
|
||||
{ #get options & args
|
||||
readonly mode=$(echo $1 | tr -d '-')
|
||||
moviedir="$1"
|
||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||
echo 'neither "movie folder" is set in global config nor given as argument'
|
||||
exit 2
|
||||
else # and (moviedir is in globalconf)
|
||||
else # and (moviedir is in globalconf)
|
||||
moviedir="$(grep "moviedir=" "$globalconf" | cut -d '=' -f 2)"
|
||||
fi
|
||||
}
|
||||
@ -55,15 +55,13 @@ function help() {
|
||||
## Programm Haupt Ablauf ##
|
||||
###########################
|
||||
function main() {
|
||||
#cd to moviedir
|
||||
cd "$moviedir"
|
||||
|
||||
#db checks
|
||||
[ "$(db_check)" == $FALSE ] && exit 1
|
||||
|
||||
#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 !
|
||||
}
|
||||
|
||||
@ -78,7 +76,7 @@ function main() {
|
||||
#all IDs wich an old check date:
|
||||
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 ...
|
||||
ID=$line
|
||||
ID=$line && echo "Progress ID: $ID"
|
||||
FILE=$(db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$ID;")
|
||||
if [ -f "$FILE" ]; then
|
||||
SIZE=$(db_query "SELECT Size FROM File WHERE ID=$ID;")
|
||||
@ -127,11 +125,11 @@ function main() {
|
||||
###########################
|
||||
|
||||
##check & prepair args
|
||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||
echo 'neither "movie folder" is set in global config nor given as argument'
|
||||
exit 2
|
||||
else # and (moviedir is in globalconf)
|
||||
else # and (moviedir is in globalconf)
|
||||
moviedir="$(grep "moviedir=" "$globalconf" | cut -d '=' -f 2)"
|
||||
fi
|
||||
}
|
||||
@ -152,7 +150,7 @@ function file_size() {
|
||||
# file_add [rel.path] (md5)
|
||||
function file_add() {
|
||||
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 folder="$(echo "$relrevpath" | cut -d '/' -f 2- | rev)"
|
||||
local FILE="$moviedir/$(echo "$relrevpath" | rev)"
|
||||
@ -162,6 +160,10 @@ function file_add() {
|
||||
}
|
||||
[ -z "$MD5" ] && MD5="$(md5sum "$FILE" | cut -c -32)"
|
||||
local SIZE="$(file_size "$FILE")"
|
||||
[ "$SIZE" -le 0 ] && {
|
||||
echo File to smal
|
||||
return 0
|
||||
}
|
||||
|
||||
#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';"
|
||||
|
||||
#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';")"
|
||||
db_query "UPDATE File SET TTSync=$TTSYNC_DEL,TTCheck='$DATE' 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 TTSync!='$TTSYNC_DEL' AND MD5!='$MD5' AND Name='$name' AND Folder='$folder';"
|
||||
|
||||
#if something MVs ...
|
||||
local IDs_mv="$(db_query "SELECT ID FROM File WHERE 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 AND 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 MD5='$MD5' AND Size='$SIZE' AND (Name!='$name' OR Folder!='$folder');"
|
||||
|
||||
#es existiert genau so ein eintrag
|
||||
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