changeset 16:64749190d772

wget.cache.wrapper: Fix regression when wget URL -O subdir/file 2011-03-02 Xerxes Ranby <xerxes@zafena.se> * buildslave/tools/wget.cache.wrapper Fix regression when wget URL -O subdir/file
author Xerxes R?nby <xerxes@zafena.se>
date Wed, 02 Mar 2011 15:25:16 +0100
parents 72316564535a
children 1e133a09a04d
files buildslave/tools/wget.cache.wrapper
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/buildslave/tools/wget.cache.wrapper	Wed Mar 02 11:45:22 2011 +0100
+++ b/buildslave/tools/wget.cache.wrapper	Wed Mar 02 15:25:16 2011 +0100
@@ -35,13 +35,14 @@
 ARG=$2
 FILE=$3
 
+CACHEDIRSUBPATH=$(dirname ${FILE})
+
 if [ ${ARG} == "-O" ] ; then
   if [ ! -e ${CACHEDIR}${URL}/${FILE} ]; then
     # file do not exist in cache
     # download the file to the cache using wget!
 
     # make sure subdirs in the cache exist
-    CACHEDIRSUBPATH=$(dirname ${FILE})
     mkdir -p ${CACHEDIR}${PID}/${URL}/${CACHEDIRSUBPATH}
     mkdir -p ${CACHEDIR}${URL}/${CACHEDIRSUBPATH}
 
@@ -50,13 +51,14 @@
     ${WGET} ${ALLARG}
 
     # atomically move the downloaded file to the main cache.
-    mv ${CACHEDIR}${PID}/${URL}/${FILE} ${CACHEDIR}${URL}/
+    mv ${CACHEDIR}${PID}/${URL}/${FILE} ${CACHEDIR}${URL}/${FILE}
   fi
 
   if [ -e ${CACHEDIR}${URL}/${FILE} ] ; then
     # ok good, file exist now in cache
     # copy the file from cache to destination
     cd ${TARGETDIR}
+    mkdir -p ${CACHEDIRSUBPATH}
     cp ${CACHEDIR}${URL}/${FILE} ${FILE}
     exit 0
   else