Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Only download mirror list when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
vbraun committed May 16, 2015
1 parent aa24229 commit 49aa3c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/bin/sage-download-file
Expand Up @@ -335,7 +335,7 @@ class Tarball(object):
sha1 = self._compute_sha1()
return sha1 == self.sha1

def download(self, mirror_list):
def download(self):
"""
Download the tarball to the upstream directory.
"""
Expand All @@ -350,7 +350,8 @@ class Tarball(object):
.format(destination=destination))
os.remove(destination)
successful_download = False
for mirror in mirror_list:
print('Attempting to download package {0} from mirrors'.format(self.filename))
for mirror in MirrorList():
url = mirror + '/'.join(['spkg', 'upstream', self.package, self.filename])
print(url)
try:
Expand Down Expand Up @@ -415,8 +416,7 @@ if __name__ == '__main__':
http_download(url, destination, progress=progress, ignore_errors=True)
else:
# url is a tarball name
mirror_list = MirrorList()
tarball = Tarball(url)
tarball.download(mirror_list)
tarball.download()
if destination is not None:
tarball.save_as(destination)
10 changes: 4 additions & 6 deletions src/bin/sage-spkg
Expand Up @@ -57,6 +57,9 @@
# Bail on errors
set -e

# This script is called in a pipe, do not let Python buffer stdout
export PYTHONUNBUFFERED=yes

# Avoid surprises with character ranges [a-z] in regular expressions
export LC_ALL=C

Expand Down Expand Up @@ -302,19 +305,14 @@ fi

# If we haven't found the package yet, we must download it
if [ ! -f "$PKG_SRC" ]; then
if [ $INFO -eq 0 ]; then
echo "Attempting to download package $PKG_NAME"
else
echo "Attempting to get on-line info for package $PKG_NAME"
fi

if [ -n "$PKG_NAME_UPSTREAM" ]; then
# This is the new-style package way of downloading the tarball
sage-download-file $PKG_NAME_UPSTREAM
PKG_SRC="$SAGE_DISTFILES/$PKG_NAME_UPSTREAM"
else
# Handle all the legacy cruft. This branch can be deleted once
# we get rid of old-style spkgs
echo "Attempting to get on-line info for package $PKG_NAME"

# Reduce everything to case 4: full URL.
if [ -n "$PKG_HAS_PATH" ]; then
Expand Down

0 comments on commit 49aa3c5

Please sign in to comment.