From 40374b3d69783047f2b0252a1b816db0b1580e31 Mon Sep 17 00:00:00 2001
From: Sam Thursfield <sam@afuera.me.uk>
Date: Thu, 17 Sep 2020 13:01:13 +0200
Subject: [PATCH] build: Use existing nw.js tarball if present

Previously we would redownload the tarball in all cases, saving it
as nwjs-*.tar.gz.1 or similar.
---
 l2ork_addons/tar_em_up.sh | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/l2ork_addons/tar_em_up.sh b/l2ork_addons/tar_em_up.sh
index f98be19d3..79e957a97 100755
--- a/l2ork_addons/tar_em_up.sh
+++ b/l2ork_addons/tar_em_up.sh
@@ -166,17 +166,23 @@ fi
 # for building with no libs, so we do it regardless of the options
 if [ ! -d "../pd/nw/nw" ]; then
 	nwjs_filename=$($script_dir/nwjs_version_for_platform.sh)
-	nwjs_version=$(echo $nwjs_filename | egrep -o 'v[^-]+')
-	nwjs_url=https://git.purrdata.net/jwilkes/nwjs-binaries/raw/master
-	nwjs_url=${nwjs_url}/$nwjs_filename
-	echo "Fetching the nwjs binary from"
-	echo "$nwjs_url"
-	if ! wget -nv $nwjs_url; then
-		nwjs_url=https://dl.nwjs.io/${nwjs_version}/$nwjs_filename
+
+	if [ -e "./$nwjs_filename" ]; then
+		echo "Found $nwjs_filename"
+	else
+		nwjs_version=$(echo $nwjs_filename | egrep -o 'v[^-]+')
+		nwjs_url=https://git.purrdata.net/jwilkes/nwjs-binaries/raw/master
+		nwjs_url=${nwjs_url}/$nwjs_filename
 		echo "Fetching the nwjs binary from"
 		echo "$nwjs_url"
-		wget -nv $nwjs_url
+		if ! wget -nv $nwjs_url; then
+			nwjs_url=https://dl.nwjs.io/${nwjs_version}/$nwjs_filename
+			echo "Fetching the nwjs binary from"
+			echo "$nwjs_url"
+			wget -nv $nwjs_url
+		fi
 	fi
+
 	if [[ $os == "win" || $os == "win64" || $os == "osx" ]]; then
 		unzip $nwjs_filename
 		nwjs_dirname=$(basename --suffix=.zip $nwjs_filename)
-- 
GitLab