USE Const Vars
- Highlight Const. (UPERCASE) - Add dumy md5 export fucntions
This commit is contained in:
parent
e3298b9272
commit
f898d4b5c1
@ -15,14 +15,18 @@
|
|||||||
# [$3]: <path to movie folder>
|
# [$3]: <path to movie folder>
|
||||||
|
|
||||||
{ #set enviroemnt
|
{ #set enviroemnt
|
||||||
true=1 #like <stdbool.h>
|
readonly TRUE=1 #like <stdbool.h>
|
||||||
false=0 #like <stdbool.h>
|
readonly FALSE=0 #like <stdbool.h>
|
||||||
globalconf="/etc/tt/global"
|
readonly TTSYNC_EXIST=0
|
||||||
|
readonly TTSYNC_BACKUP=1
|
||||||
|
readonly TTSYNC_REMOTE=2
|
||||||
|
readonly TTSYNC_DEL=3
|
||||||
|
readonly globalconf="/etc/tt/global"
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #get options & args
|
{ #get options & args
|
||||||
mode=$(echo $1 | tr -d '-')
|
readonly mode=$(echo $1 | tr -d '-')
|
||||||
md5="$2"
|
readonly md5="$2"
|
||||||
moviedir="$3"
|
moviedir="$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +56,7 @@ function help() {
|
|||||||
if [ "$mode" == "help" ] && help
|
if [ "$mode" == "help" ] && help
|
||||||
|
|
||||||
##check & prepair args
|
##check & prepair args
|
||||||
|
[ ${mode:0:1} == "e" ] && touch "$md5"
|
||||||
[ -f "$md5" ] || { echo "md5 \"$md5\" do not exist"; exit 1; } # check md5
|
[ -f "$md5" ] || { echo "md5 \"$md5\" do not exist"; exit 1; } # check md5
|
||||||
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
[ -z "$moviedir" ] && [ -f "$globalconf" ] && { # if (no argument) and (globalconf exist)
|
||||||
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
if [ -z "$(grep "moviedir=" "$globalconf" )" ]; then # and (moviedir is NOT in globalconf)
|
||||||
@ -73,7 +78,7 @@ function md5_in_add() {
|
|||||||
relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev)
|
relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev)
|
||||||
name=$(echo $relrevpath | cut -d '/' -f 1 | rev)
|
name=$(echo $relrevpath | cut -d '/' -f 1 | rev)
|
||||||
folder=$(echo $relrevpath | cut -d '/' -f 2- | rev)
|
folder=$(echo $relrevpath | cut -d '/' -f 2- | rev)
|
||||||
db_query "INSERT INTO File (MD5, Folder, Name) VALUES ('$md5', '$folder', '$name' );" #-> handle in future: ";'()"
|
db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );" #-> handle in future: ";'()"
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@ -88,10 +93,12 @@ function md5_in_del() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function md5_out_exist() {
|
function md5_out_exist() {
|
||||||
|
db_query "SELECT CONCAT(MD5, ' ', ' ' ,'$moviedir/', Folder, '/', Name) FROM File WHERE TTSync=$TTSYNC_EXIST OR TTSync=$TTSYNC_BACKUP;"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function md5_out_del() {
|
function md5_out_del() {
|
||||||
|
db_query "SELECT CONCAT(MD5, ' ', ' ' ,'$moviedir/', Folder, '/', Name) FROM File WHERE TTSync=$TTSYNC_DEL;"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,19 +119,16 @@ function db_exist_md5() {
|
|||||||
result=($(db_query "SELECT COUNT(md5) FROM File WHERE File.MD5 LIKE '$1';"))
|
result=($(db_query "SELECT COUNT(md5) FROM File WHERE File.MD5 LIKE '$1';"))
|
||||||
if [ "${result[2]}" -gt "0" ]; then
|
if [ "${result[2]}" -gt "0" ]; then
|
||||||
echo true
|
echo true
|
||||||
return $true
|
return $TRUE
|
||||||
else
|
else
|
||||||
echo false
|
echo false
|
||||||
return $false
|
return $FALSE
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# db_F-ID_getPath <F-ID> -> <Path>
|
# db_F-ID_getPath <F-ID> -> <Path>
|
||||||
function db_id_getPath() {
|
function db_id_getPath() {
|
||||||
local ID=$1
|
db_query "SELECT CONCAT('$moviedir/', Folder, '/', Name) FROM File WHERE ID=$1;"
|
||||||
local Folder=$(db_query "SELECT Folder FROM File WHERE ID=$ID;")
|
|
||||||
local Name=$(db_query "SELECT Name FROM File WHERE ID=$ID;")
|
|
||||||
echo "$moviedir/$Folder/$Name"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
|
Loading…
Reference in New Issue
Block a user