Update dlmodels.sh
Browse files- dlmodels.sh +12 -7
dlmodels.sh
CHANGED
|
@@ -16,17 +16,22 @@ download_file() {
|
|
| 16 |
|
| 17 |
echo -e "\nChecking file: $filepath"
|
| 18 |
|
| 19 |
-
# If
|
| 20 |
if [[ -f "$filepath" ]]; then
|
| 21 |
-
# Get remote file size using curl
|
| 22 |
-
remote_size=$(curl -sI "$url" |
|
| 23 |
-
# Get local file size
|
| 24 |
local_size=$(stat -c%s "$filepath")
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
echo "Remote size: $remote_size, Local size: $local_size for file $filepath"
|
| 28 |
|
| 29 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
if [[ "$remote_size" == "$local_size" ]]; then
|
| 31 |
echo -e "[SKIP] $filepath already exists and is complete."
|
| 32 |
return 0
|
|
|
|
| 16 |
|
| 17 |
echo -e "\nChecking file: $filepath"
|
| 18 |
|
| 19 |
+
# If file already exists, check its integrity
|
| 20 |
if [[ -f "$filepath" ]]; then
|
| 21 |
+
# Get the remote file size using a reliable curl method
|
| 22 |
+
remote_size=$(curl -sI "$url" | grep -i "Content-Length" | awk '{print $2}' | tr -d '\r')
|
|
|
|
| 23 |
local_size=$(stat -c%s "$filepath")
|
| 24 |
|
| 25 |
+
# Debug output
|
| 26 |
+
echo "Remote size: ${remote_size:-Unknown}, Local size: $local_size for file $filepath"
|
| 27 |
|
| 28 |
+
# Handle cases where Content-Length is not available
|
| 29 |
+
if [[ -z "$remote_size" ]]; then
|
| 30 |
+
echo -e "[SKIP] Unable to verify size for $filepath (no Content-Length). Assuming complete."
|
| 31 |
+
return 0
|
| 32 |
+
fi
|
| 33 |
+
|
| 34 |
+
# If the file sizes match, skip the download
|
| 35 |
if [[ "$remote_size" == "$local_size" ]]; then
|
| 36 |
echo -e "[SKIP] $filepath already exists and is complete."
|
| 37 |
return 0
|