[Lunar-commits] <lunar> downloader: fix some not-well tested codepaths.

Auke Kok sofar at foo-projects.org
Sun Jan 29 07:29:46 CET 2012


commit 94038104022a043d2bfe3ef6fad4246882a40dbe
Author: Auke Kok <sofar at foo-projects.org>
Date:   Sat Jan 28 22:29:46 2012 -0800

    downloader: fix some not-well tested codepaths.
    
    This was broken in several ways. The plugins return '2' when they
    fail since more plugins need to be tried, but, we need to trap
    the error code in the main loop in download_module, and not in
    download_url. Taking the error code handling out fixes that problem
    which caused the downloader to only try the first tarball URL.
    
    Second problem was that the mirror inserter should append behind
    all the listed URLS, not in between url[0] and url[1].
---
 var/lib/lunar/functions/download.lunar |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/var/lib/lunar/functions/download.lunar b/var/lib/lunar/functions/download.lunar
index 893f77d..6075e89 100644
--- a/var/lib/lunar/functions/download.lunar
+++ b/var/lib/lunar/functions/download.lunar
@@ -39,15 +39,7 @@ download_url() {
 	verbose_msg "trying to download \"${2}\" from \"${1}\""
 	connect &&
 	plugin_call SOURCE_DOWNLOAD $1 $2 $3
-	RETVAL=$?
-	if [ $RETVAL == 2 ]; then
-		# refuse to continue - it's useless to have the user attempt to
-		# download cvs/svn etc snapshots from the cache URLs
-		error_message "${PROBLEM_COLOR}I don't know how to download ${QUERY_COLOR}\"$1\".${DEFAULT_COLOR}"
-		error_message "${MESSAGE_COLOR}Install the package that provides the method and plugin to download it.${DEFAULT_COLOR}"
-		exit 1
-	fi
-	return $RETVAL
+	return $?
 }
 
 
@@ -94,6 +86,7 @@ download_module() {
 		add_url() {
 			if [ -n "$1" ]; then
 				if ! echo " $ALL_URLS " | grep -q " $1 "; then
+echo Inserting $1...
 					ALL_URLS="$ALL_URLS $1"
 				fi
 			fi
@@ -120,6 +113,8 @@ download_module() {
 			add_url $FRESORT_URL
 			for URL in $URLS ; do
 				add_url $URL
+			done
+			for URL in $URLS ; do
 				if [ "$EXHAUSTIVE" != "on" ]; then
 					continue
 				fi
@@ -142,17 +137,20 @@ download_module() {
 
 		for URL in $ALL_URLS; do
 			# and download
-			if download_url $URL $SRC $SOURCE_CACHE ; then
+			if download_url $URL $SRC $SOURCE_CACHE == 0 ; then
 				# done for this file!
-				FAILED=1
+				SUCCESS=1
 				break
 			fi
 		done
-		if [ ${FAILED:-0} == 0 ] ; then
+		if [ ${SUCCESS:-0} == 0 ] ; then
 			FAILALL=1
+			error_message "${PROBLEM_COLOR}I don't know how to download ${QUERY_COLOR}\"$1\".${DEFAULT_COLOR}"
+			error_message "${MESSAGE_COLOR}Install the package that provides the method and plugin to download it.${DEFAULT_COLOR}"
 		fi
 
 	done
+
 	return ${FAILALL:-0}
 )
 }


More information about the Lunar-commits mailing list