Fixes for consumedir.sh

- The `-e` option on realpath is not available in busybox
- Avoid creating sha checksum twice
This commit is contained in:
Eike Kettner
2020-06-28 02:10:45 +02:00
parent f5fd4e9310
commit df73bc6285

View File

@ -167,8 +167,8 @@ info() {
} }
getCollective() { getCollective() {
file="$(realpath -e $1)" file="$(realpath $1)"
dir="$(realpath -e $2)" dir="$(realpath $2)"
collective=${file#"$dir"} collective=${file#"$dir"}
coll=$(echo $collective | cut -d'/' -f1) coll=$(echo $collective | cut -d'/' -f1)
if [ -z "$coll" ]; then if [ -z "$coll" ]; then
@ -179,8 +179,8 @@ getCollective() {
upload() { upload() {
dir="$(realpath -e $1)" dir="$(realpath $1)"
file="$(realpath -e $2)" file="$(realpath $2)"
url="$3" url="$3"
OPTS="$CURL_OPTS" OPTS="$CURL_OPTS"
if [ "$integration" = "y" ]; then if [ "$integration" = "y" ]; then
@ -245,10 +245,10 @@ checkFile() {
else else
url=$(echo "$1" | sed 's,upload/item,checkfile,g') url=$(echo "$1" | sed 's,upload/item,checkfile,g')
fi fi
trace "- Check file: $url/$(checksum $file)" url="$url/$(checksum $file)"
trace "- Check file via $OPTS: $url"
tf1=$($MKTEMP_CMD) tf2=$($MKTEMP_CMD) tf1=$($MKTEMP_CMD) tf2=$($MKTEMP_CMD)
$CURL_CMD --fail -o "$tf1" --stderr "$tf2" $OPTS -XGET -s "$url"
$CURL_CMD --fail -o "$tf1" --stderr "$tf2" $OPTS -XGET -s "$url/$(checksum "$file")"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
info "Checking file failed!" info "Checking file failed!"
cat "$tf1" >&2 cat "$tf1" >&2
@ -269,7 +269,7 @@ checkFile() {
} }
process() { process() {
file="$(realpath -e $1)" file="$(realpath $1)"
dir="$2" dir="$2"
info "---- Processing $file ----------" info "---- Processing $file ----------"
declare -i curlrc=0 declare -i curlrc=0
@ -345,6 +345,6 @@ else
dir=$(findDir "$path") dir=$(findDir "$path")
trace "The file '$file' appeared in directory '$path' below '$dir' via '$action'" trace "The file '$file' appeared in directory '$path' below '$dir' via '$action'"
sleep 1 sleep 1
process "$(realpath -e "$path$file")" "$dir" process "$(realpath "$path$file")" "$dir"
done done
fi fi