Skip to content

Commit

Permalink
$id was removed but still used, compute base file name inside the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Aug 18, 2017
1 parent 6915d6b commit 5e9656b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/fetch-basefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# fetch-basefile, fetch a basefile via ftp or http using classes
#
# (c) Thomas Lange, 2011-2012
# (c) Thomas Lange, 2011-2017
#
# Try to download a file CLASSNAME.tar.gz (or tgz, or tar.xz,...) from an URL
# CLASSNAME must match a FAI class
Expand Down Expand Up @@ -41,7 +41,6 @@ done
flist=$(lftp -e 'cls;exit' $url 2>/dev/null)
# create an array of all lines
baselist=($flist)
baselist=("${baselist[@]%%.*}")

# reverse order of classes
for c in $classes; do
Expand All @@ -51,24 +50,23 @@ done
# now search for each class, if a basename matches
for c in $revclasses; do
for f in ${baselist[@]}; do
if [ "$c" = "$f" ]; then
# hash lookup succeeded
base=${f%%.*}
if [ "$c" = "$base" ]; then
found=1
[ $mount = 1 ] && mount_ramdisk
# Create folder in case it is not part of the configuration space
mkdir -p $FAI/basefiles || echo "Could not create folder $FAI/basefiles" >&2
cd $FAI/basefiles || exit 3
if [ -f ${!id} ]; then
echo "${!id} already exists" >&2
if [ -f $f ]; then
echo "$f already exists" >&2
error=1
break
break 2
fi

echo "Downloading $url/${!id}"
# wget -nv $url/${!id} # creates a new file with suffix .1, .2,.. if file already exists. Bad.
lftp -e "get $url/${!id};exit" # fails if file already exists. this is nice.
echo "Downloading $url/$f"
lftp -e "get $url/$f;exit" # fails if file already exists. this is nice.
error=$?
break
break 2
fi
done
done
Expand Down

0 comments on commit 5e9656b

Please sign in to comment.