Merge pull request #851 from eikek/fix/older-jq-for-scripts

Don't use jq to clean whitespace/quotes
This commit is contained in:
mergify[bot] 2021-06-03 19:31:13 +00:00 committed by GitHub
commit ea97e0c60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -150,7 +150,7 @@ downloadAttachment() {
DL_URL="$ATTACH_URL/$attachId" DL_URL="$ATTACH_URL/$attachId"
checksum1=$("$CURL_CMD" -s -I -H "X-Docspell-Auth: $auth_token" "$DL_URL" | \ checksum1=$("$CURL_CMD" -s -I -H "X-Docspell-Auth: $auth_token" "$DL_URL" | \
grep -i 'etag' | cut -d' ' -f2 | "$JQ_CMD" -r) grep -i 'etag' | cut -d' ' -f2 | xargs | tr -d '\r')
"$CURL_CMD" -s -o "$attachOut" -H "X-Docspell-Auth: $auth_token" "$DL_URL" "$CURL_CMD" -s -o "$attachOut" -H "X-Docspell-Auth: $auth_token" "$DL_URL"
checksum2=$(sha256sum "$attachOut" | cut -d' ' -f1 | xargs) checksum2=$(sha256sum "$attachOut" | cut -d' ' -f1 | xargs)
if [ "$checksum1" == "$checksum2" ]; then if [ "$checksum1" == "$checksum2" ]; then

View File

@ -178,7 +178,7 @@ downloadAttachment() {
fi fi
checksum1=$("$CURL_CMD" -s -I -H "X-Docspell-Auth: $auth_token" "$ATTACH_URL/$attachId/original" | \ checksum1=$("$CURL_CMD" -s -I -H "X-Docspell-Auth: $auth_token" "$ATTACH_URL/$attachId/original" | \
grep -i 'etag' | cut -d' ' -f2 | "$JQ_CMD" -r) grep -i 'etag' | cut -d':' -f2 | xargs | tr -d '\r')
"$CURL_CMD" -s -o "$attachOut" -H "X-Docspell-Auth: $auth_token" "$ATTACH_URL/$attachId/original" "$CURL_CMD" -s -o "$attachOut" -H "X-Docspell-Auth: $auth_token" "$ATTACH_URL/$attachId/original"
checksum2=$(sha256sum "$attachOut" | cut -d' ' -f1 | xargs) checksum2=$(sha256sum "$attachOut" | cut -d' ' -f1 | xargs)
if [ "$checksum1" == "$checksum2" ]; then if [ "$checksum1" == "$checksum2" ]; then
@ -212,15 +212,13 @@ downloadItem() {
errout " - Removing metadata.json as requested" errout " - Removing metadata.json as requested"
rm -f "$out/metadata.json" rm -f "$out/metadata.json"
fi fi
echo $itemData | "$JQ_CMD" > "$out/metadata.json" echo $itemData > "$out/metadata.json"
fi fi
while read attachId attachName; do while read attachId attachName; do
attachOut="$out/$attachName" attachOut="$out/$attachName"
checkLogin checkLogin
downloadAttachment "$attachId" downloadAttachment "$attachId"
done < <(echo $itemData | "$JQ_CMD" -r '.sources[] | [.id,.name] | join(" ")') done < <(echo $itemData | "$JQ_CMD" -r '.sources[] | [.id,.name] | join(" ")')
} }
login login