diff options
author | Youness Alaoui <kakaroto@kakaroto.homelinux.net> | 2016-03-31 16:55:56 +0300 |
---|---|---|
committer | Youness Alaoui <kakaroto@kakaroto.homelinux.net> | 2016-04-01 22:48:24 +0300 |
commit | 35a749f055bea92d4609b821a77babb90362d2a0 (patch) | |
tree | fe3335a6aa6c6737756a907c1acbb607622aa098 | |
parent | efa6acd5d5d3841ebc3c0f07110d556e076f82f8 (diff) |
package.sh: When downloading files, if file exists, check that it has the right size
If a file was not downloaded correctly, this caused an issue where it would
never try to redownload it. This should fix it (not tested properly though)
-rwxr-xr-x | package.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/package.sh b/package.sh index e68a264239..4ee2f7efb0 100755 --- a/package.sh +++ b/package.sh @@ -61,6 +61,14 @@ function downloadURL { filename=`basename "$1"` echo "Checking for $filename" + if [ -f "$filename" ]; then + SERVER_SIZE=$(curl -L -I "$1" | grep Content-Length | awk '{print $2}') + FILE_SIZE=$(stat -c%s "$filename") + echo "File $filename exists with $FILE_SIZE bytes. Server version has $SERVER_SIZE bytes" + if [ "$FILE_SIZE" != "$SERVER_SIZE" ]; then + rm -f "$filename" + fi + fi if [ ! -f "$filename" ]; then echo "Downloading $1" curl -L -O "$1" |