compress="no" seems to allow for much better zip/xz compression rates (~30% better)

This commit is contained in:
Reinhard Pointner 2016-10-25 04:17:47 +08:00
parent acee061e0e
commit 1a6a95f94b
1 changed files with 18 additions and 15 deletions

View File

@ -23,32 +23,35 @@ cd "$WORKING_DIR"
# update core application files
JAR_FILE="$APP_ROOT/FileBot.jar"
JAR_URL="https://sourceforge.net/projects/filebot/files/filebot/HEAD/FileBot.jar"
JAR_XZ_FILE="$APP_ROOT/FileBot.jar.xz"
JAR_XZ_URL="https://sourceforge.net/projects/filebot/files/filebot/HEAD/FileBot.jar.xz"
# check if file has changed
JAR_SHA1_EXPECTED=`curl --retry 5 "$JAR_URL/list" | egrep -o "[a-z0-9]{40}"`
JAR_SHA1=`sha1sum $JAR_FILE | cut -d' ' -f1`
JAR_XZ_SHA1_EXPECTED=`curl --retry 5 "$JAR_XZ_URL/list" | egrep -o "[a-z0-9]{40}"`
JAR_XZ_SHA1=`sha1sum $JAR_XZ_FILE | cut -d' ' -f1`
if [ -z "$JAR_SHA1_EXPECTED" ]; then
if [ -z "$JAR_XZ_SHA1_EXPECTED" ]; then
echo "SHA1 hash unknown"
exit 1
fi
if [ "$JAR_SHA1" == "$JAR_SHA1_EXPECTED" ]; then
echo "$JAR_FILE [SHA1: $JAR_SHA1]"
if [ "$JAR_XZ_SHA1" == "$JAR_XZ_SHA1_EXPECTED" ]; then
echo "$JAR_XZ_FILE [SHA1: $JAR_XZ_SHA1]"
exit 0
fi
echo "Update $JAR_FILE"
curl -L -o "$JAR_FILE" -z "$JAR_FILE" --retry 5 "$JAR_URL" # FRS will redirect to (unsecure) HTTP download link
echo "Update $JAR_XZ_FILE"
curl -L -o "$JAR_XZ_FILE" -z "$JAR_XZ_FILE" --retry 5 "$JAR_XZ_URL" # FRS will redirect to (unsecure) HTTP download link
# check if file has been corrupted
JAR_SHA1=`sha1sum $JAR_FILE | cut -d' ' -f1`
echo "$JAR_FILE [SHA1: $JAR_SHA1]"
# check if file has been corrupted (or modified) in transit
JAR_XZ_SHA1=`sha1sum $JAR_XZ_FILE | cut -d' ' -f1`
echo "$JAR_XZ_FILE [SHA1: $JAR_XZ_SHA1]"
if [ "$JAR_SHA1" != "$JAR_SHA1_EXPECTED" ]; then
echo "SHA1 hash mismatch [SHA1: $JAR_SHA1_EXPECTED]"
rm -vf "$JAR_FILE"
if [ "$JAR_XZ_SHA1" != "$JAR_XZ_SHA1_EXPECTED" ]; then
echo "SHA1 hash mismatch [SHA1: $JAR_XZ_SHA1_EXPECTED]"
rm -vf "$JAR_XZ_FILE"
exit 1
fi
# unpack new jar
xz --decompress --force --keep "$JAR_XZ_FILE"