From 8c2b505caf76b2b014fbe23d8a1d52e3c8a3718f Mon Sep 17 00:00:00 2001 From: Pierre Labastie Date: Fri, 1 Apr 2022 10:18:15 +0200 Subject: [PATCH] Fix small bugs in func_download_pkgs - If MISSING_FILES.DMP is left from a preceding attempt, it may generate a false warning a bout missing files even if they could all be downloaded. - do not try to copy a modified file to SRC_ARCHIVE if it already exists: it may belong to another user... --- common/libs/func_download_pkgs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/libs/func_download_pkgs b/common/libs/func_download_pkgs index f2b23c7..537f6c0 100644 --- a/common/libs/func_download_pkgs +++ b/common/libs/func_download_pkgs @@ -3,6 +3,10 @@ #----------------------------# get_sources() { # Download file, write name to MISSING_FILES.DMP if an error #----------------------------# + + # Test if the packages must be downloaded + [ ! "$GETPKG" = "y" ] && return + local saveIFS=$IFS local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM @@ -13,9 +17,6 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if WGETPARAM+=" --tries ${RETRYDOWNLOADCNT}" WGETPARAM+=" --timeout ${DOWNLOADTIMEOUT}" - # Test if the packages must be downloaded - [ ! "$GETPKG" = "y" ] && return - gs_wrt_message(){ echo "${RED}$1${OFF}" echo "$1" >> MISSING_FILES.DMP @@ -27,6 +28,9 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if # Generate URLs file create_urls + # Clean up leftovers from preceding attempts + >MISSING_FILES.DMP + IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only for line in `cat urls.lst`; do IFS=$saveIFS # Restore the system defaults @@ -110,6 +114,7 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if if [ ! -z ${SRC_ARCHIVE} ] && [ -d ${SRC_ARCHIVE} ] && [ -w ${SRC_ARCHIVE} ] && + [ ! -f ${SRC_ARCHIVE}/$FILE ] && [ "$fromARCHIVE" = "0" ] ; then echo "Storing file:<$FILE> in the package archive" cp -f $FILE ${SRC_ARCHIVE}