diff options
author | Youness Alaoui <kakaroto@kakaroto.homelinux.net> | 2016-03-31 16:55:56 +0300 |
---|---|---|
committer | Youness Alaoui <kakaroto@kakaroto.homelinux.net> | 2016-03-31 16:56:54 +0300 |
commit | 0163f9919ccf87938df6751fdfdb0cc05d8372b9 (patch) | |
tree | 11021f588bd9e9393762e1f2800570e39d28f2d9 | |
parent | 8bbf6bbe97cc05be04422a471a2305fe631cd9cf (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" |