[game-data-packager] 01/01: downloads: half-revert + half-improve on last commit

Alexandre Detiste detiste-guest at moszumanska.debian.org
Wed Jan 6 16:04:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit d070a62556bd6797cf377c2ec87c352f1717f4d0
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Wed Jan 6 17:04:00 2016 +0100

    downloads: half-revert + half-improve on last commit
---
 game_data_packager/build.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index c20c28a..feffe3c 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -899,16 +899,7 @@ class PackagingTask(object):
 
                     logger.debug('... %s', url)
 
-                    if self.save_downloads is not None:
-                        tmp = os.path.join(self.save_downloads,
-                                wanted.name)
-                        tmpdir = os.path.dirname(tmp)
-                    else:
-                        tmp = os.path.join(self.get_workdir(),
-                                'tmp', wanted.name)
-                        tmpdir = os.path.dirname(tmp)
-                        mkdir_p(tmpdir)
-
+                    tmpdir = self.save_downloads or os.path.dirname(self.get_workdir())
                     statvfs = os.statvfs(tmpdir)
                     if wanted.size > statvfs.f_frsize * statvfs.f_bavail:
                         logger.error("Out of space on %s, can't download %s.",
@@ -916,12 +907,21 @@ class PackagingTask(object):
                         self.download_failed.add(url)
                         return FillResult.IMPOSSIBLE
 
+                    tmp = None
                     try:
                         rf = urllib.request.urlopen(urllib.request.Request(
                                          url,headers={'User-Agent': AGENT}))
                         if rf is None:
                             continue
 
+                        if self.save_downloads is not None:
+                            tmp = os.path.join(self.save_downloads,
+                                    wanted.name)
+                        else:
+                            tmp = os.path.join(self.get_workdir(),
+                                    'tmp', wanted.name)
+                            mkdir_p(os.path.dirname(tmp))
+
                         wf = open(tmp, 'wb')
                         logger.info('downloading %s', url)
                         hf = HashedFile.from_file(url, rf, wf,
@@ -940,7 +940,8 @@ class PackagingTask(object):
                         logger.warning('Failed to download "%s": %s', url,
                                 e)
                         self.download_failed.add(url)
-                        os.remove(tmp)
+                        if tmp is not None:
+                            os.remove(tmp)
 
         providers = list(self.game.providers.get(wanted.name, ()))
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list