[PC-BSD Commits] r12145 - pcbsd/current/src-sh/pc-updatemanager

svn at pcbsd.org svn at pcbsd.org
Thu Aug 18 07:58:40 PDT 2011


Author: kris
Date: 2011-08-18 07:58:40 -0700 (Thu, 18 Aug 2011)
New Revision: 12145

Modified:
   pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
Log:

Improve the FTP download failure tolerance to try more than once after 



Modified: pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
===================================================================
--- pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2011-08-18 14:51:40 UTC (rev 12144)
+++ pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2011-08-18 14:58:40 UTC (rev 12145)
@@ -300,62 +300,88 @@
   local FETCHOUTFILE="$2"
   local EXITFAILED="$3"
 
-  # If the var PCFETCHGUI is unset, use regular fetch command
-  if [ -z "$PCFETCHGUI" ] ; then
-    fetch -o ${FETCHOUTFILE} "${FETCHFILE}"
-    return $?
-  fi
+  local numAtt=0
 
-  SIZEFILE="${DOWNLOADDIR}/.fetchSize"
-  EXITFILE="${DOWNLOADDIR}/.fetchExit"
-
-  rm ${SIZEFILE} 2>/dev/null >/dev/null
-  rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
-
-  fetch -s "${FETCHFILE}" >${SIZEFILE}
-  SIZE="`cat ${SIZEFILE}`"
-  SIZE="`expr ${SIZE} / 1024 2>/dev/null`"
-  echo "FETCH: ${FETCHFILE}"
-  echo "FETCH: ${FETCHOUTFILE}" >>${TRIGGERFILE}
-
-  ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
-  PID="$!"
   while
   z=1
   do
-
-    if [ -e "${FETCHOUTFILE}" ]
-    then
-      DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
-      if [ $(is_num "$DSIZE") ] ; then
-      if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi 
-    	echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}"
-    	echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${TRIGGERFILE}
+    numAtt=`expr $numAtt + 1`
+    # If the var PCFETCHGUI is unset, use regular fetch command
+    if [ -z "$PCFETCHGUI" ] ; then
+      fetch -o ${FETCHOUTFILE} "${FETCHFILE}"
+      if [ $? -eq 0 ] ; then return 0 ; fi
+      if [ $numAtt -gt 3 ] ; then 
+        return 1
+      else
+ 	sleep 1
+	continue
       fi
     fi
 
-    # Check if the download is finished
-    ps -p ${PID} >/dev/null 2>/dev/null
-    if [ $? -ne 0 ]
-    then
+    SIZEFILE="${DOWNLOADDIR}/.fetchSize"
+    EXITFILE="${DOWNLOADDIR}/.fetchExit"
+
+    rm ${SIZEFILE} 2>/dev/null >/dev/null
+    rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
+
+    fetch -s "${FETCHFILE}" >${SIZEFILE}
+    SIZE="`cat ${SIZEFILE}`"
+    SIZE="`expr ${SIZE} / 1024 2>/dev/null`"
+    echo "FETCH: ${FETCHFILE}"
+    echo "FETCH: ${FETCHOUTFILE}" >>${TRIGGERFILE}
+ 
+    ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
+    PID="$!"
+    while
+    z=1
+    do
+
+      if [ -e "${FETCHOUTFILE}" ]
+      then
+        DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
+        if [ $(is_num "$DSIZE") ] ; then
+        if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi 
+      	  echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}"
+    	  echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${TRIGGERFILE}
+        fi
+      fi
+
+      # Check if the download is finished
+      ps -p ${PID} >/dev/null 2>/dev/null
+      if [ $? -ne 0 ]
+      then
       break;
-    fi
+      fi
 
-    sleep 2
-  done
+      sleep 2
+    done
 
-  echo "FETCHDONE"
+    echo "FETCHDONE"
 
-  EXIT="`cat ${EXITFILE}`"
-  rm ${SIZEFILE} 2>/dev/null >/dev/null
-  rm ${EXITFILE} 2>/dev/null >/dev/null
+    EXIT="`cat ${EXITFILE}`"
+    rm ${SIZEFILE} 2>/dev/null >/dev/null
+    rm ${EXITFILE} 2>/dev/null >/dev/null
 
-  if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
-  then
-    exit_err "Error: Failed to download ${FETCHFILE}"
-  fi
+    if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]; then
+      if [ $numAtt -gt 3 ] ; then 
+        exit_err "Error: Failed to download ${FETCHFILE}"
+      else
+        sleep 1
+	continue
+      fi
+    fi
 
-  return $EXIT
+    if [ "${EXIT}" = "0" ]; then
+      return 0
+    else
+      if [ $numAtt -gt 3 ] ; then 
+        return -1
+      else
+	sleep 1
+	continue
+      fi
+    fi
+  done
 
 };
 



More information about the Commits mailing list