[game-data-packager] 01/01: mirror: use simpler logic to pick an unique version of a file
    Alexandre Detiste 
    detiste-guest at moszumanska.debian.org
       
    Tue May 10 11:51:52 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 9b3c3902af7af1775f04d7f0329007546da7777b
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue May 10 13:48:29 2016 +0200
    mirror: use simpler logic to pick an unique version of a file
    
    original tnt31fix.zip is not hosted anymore anywhere,
    just pick up the smallest repack instead.
    
    current mirror managers (if any ?) will have to move
    the original tnt31fix.zip out of the way.
---
 tools/mirror.py | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/tools/mirror.py b/tools/mirror.py
index 89de264..b4178c6 100755
--- a/tools/mirror.py
+++ b/tools/mirror.py
@@ -77,22 +77,16 @@ for gamename, game in load_games().items():
              'download': url,
              })
 
-# avoid to download both "tnt31fix.zip" and "tnt31fix.zip?repack"
-# always prefer the one 'regular' file without the '?xxx' suffix
-names = dict()
-for archive in archives:
-    name = archive['name']
-    names[name] = names.get(name, 0) + 1
-
-for k, count in names.items():
-    if count > 1:
-        for archive in archives:
-            if archive['name'] == k and archive['filename'] != archive['name']:
-                archives.remove(archive)
-
 archives = sorted(archives, key=lambda k: (k['size']))
 
+seen = set()
+
 for a in archives:
+   # always prefer the smallest version of a file (e.g.: tnt31fix.zip)
+   if a['name'] in seen:
+       continue
+   seen.add(a['name'])
+
    archive = os.path.join(args.destination, a['name'])
 
    if not os.path.isfile(archive):
-- 
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