remove redundancy code

This commit is contained in:
6543 2019-05-12 00:53:13 +02:00
parent 3d291d2e6d
commit 8f1e932f1a

View File

@ -29,6 +29,7 @@ readonly DATE=$(date '+%Y-%m-%d')
echo "$0 is part of the TerabyteTerminator Project"
echo ""
echo "update-file-state (moviedir)"
echo "config: $globalconf"
exit 0
}

@ -108,22 +109,9 @@ function main() {
}

###########################
## help functions #########
## sub functions #########
###########################

##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)
echo 'neither "movie folder" is set in global config nor given as argument'
exit 2
else # and (moviedir is in globalconf)
moviedir="$(grep "moviedir=" "$globalconf" | cut -d '=' -f 2)"
fi
}
[ -d "$moviedir" ] || { echo "moviedir \"$moviedir\" do not exist"; exit 3; } # check moviedir
moviedir=""$(echo $moviedir | sed 's|/$||g')""
[ -z "$moviedir" ] && exit 255 #catch case moviedir="/"

# file_add [rel.path] (md5)
function file_add() {
local MD5="$2"