Update dlmodels.sh
Browse files- dlmodels.sh +9 -7
dlmodels.sh
CHANGED
|
@@ -14,29 +14,31 @@ download_file() {
|
|
| 14 |
local filepath="$1"
|
| 15 |
local url="$2"
|
| 16 |
|
| 17 |
-
# Display progress message
|
| 18 |
echo -e "\nChecking file: $filepath"
|
| 19 |
|
| 20 |
-
# If file already exists
|
| 21 |
if [[ -f "$filepath" ]]; then
|
| 22 |
-
# Get
|
| 23 |
remote_size=$(curl -sI "$url" | awk '/Content-Length/ {print $2}' | tr -d '\r')
|
| 24 |
-
# Get
|
| 25 |
local_size=$(stat -c%s "$filepath")
|
| 26 |
|
| 27 |
-
#
|
|
|
|
|
|
|
|
|
|
| 28 |
if [[ "$remote_size" == "$local_size" ]]; then
|
| 29 |
echo -e "[SKIP] $filepath already exists and is complete."
|
| 30 |
return 0
|
| 31 |
else
|
| 32 |
-
echo -e "[RE-DOWNLOAD] $filepath is incomplete or corrupted
|
| 33 |
rm -f "$filepath" # Remove the corrupted file
|
| 34 |
fi
|
| 35 |
else
|
| 36 |
echo -e "[DOWNLOAD] Starting download of $filepath"
|
| 37 |
fi
|
| 38 |
|
| 39 |
-
# Download the file with wget
|
| 40 |
wget -c --progress=dot -O "$filepath" "$url" 2>&1 | \
|
| 41 |
grep --line-buffered "%" | \
|
| 42 |
sed -u -e "s,\.,,g" | \
|
|
|
|
| 14 |
local filepath="$1"
|
| 15 |
local url="$2"
|
| 16 |
|
|
|
|
| 17 |
echo -e "\nChecking file: $filepath"
|
| 18 |
|
| 19 |
+
# If the file already exists, check its integrity
|
| 20 |
if [[ -f "$filepath" ]]; then
|
| 21 |
+
# Get remote file size using curl
|
| 22 |
remote_size=$(curl -sI "$url" | awk '/Content-Length/ {print $2}' | tr -d '\r')
|
| 23 |
+
# Get local file size
|
| 24 |
local_size=$(stat -c%s "$filepath")
|
| 25 |
|
| 26 |
+
# Debugging output to understand size comparison
|
| 27 |
+
echo "Remote size: $remote_size, Local size: $local_size for file $filepath"
|
| 28 |
+
|
| 29 |
+
# If the file sizes match, skip download
|
| 30 |
if [[ "$remote_size" == "$local_size" ]]; then
|
| 31 |
echo -e "[SKIP] $filepath already exists and is complete."
|
| 32 |
return 0
|
| 33 |
else
|
| 34 |
+
echo -e "[RE-DOWNLOAD] $filepath is incomplete or corrupted. Re-downloading..."
|
| 35 |
rm -f "$filepath" # Remove the corrupted file
|
| 36 |
fi
|
| 37 |
else
|
| 38 |
echo -e "[DOWNLOAD] Starting download of $filepath"
|
| 39 |
fi
|
| 40 |
|
| 41 |
+
# Download the file with wget, showing a clean progress indicator
|
| 42 |
wget -c --progress=dot -O "$filepath" "$url" 2>&1 | \
|
| 43 |
grep --line-buffered "%" | \
|
| 44 |
sed -u -e "s,\.,,g" | \
|