[game-data-packager] 01/01: remove tnt31fix.zip?repack special casing in mirroring tool
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Sat May 7 09:35:39 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 0956c8a0510302cdd5bf728e6bff7f6802f5084d
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Sat May 7 11:35:02 2016 +0200
remove tnt31fix.zip?repack special casing in mirroring tool
---
tools/mirror.py | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/tools/mirror.py b/tools/mirror.py
index 85a4a6b..89de264 100755
--- a/tools/mirror.py
+++ b/tools/mirror.py
@@ -58,20 +58,18 @@ for gamename, game in load_games().items():
elif not file.download:
continue
- if filename == 'tnt31fix.zip?repack':
- continue
+ url = choose_mirror(file)[0]
+ if '?' not in url:
+ destname = os.path.basename(url)
+ elif '?' not in filename:
+ destname = filename
+ elif url.endswith('?download'):
+ destname = os.path.basename(url)
+ destname = destname[0:len(destname)-len('?download')]
else:
- url = choose_mirror(file)[0]
- if '?' not in url:
- destname = os.path.basename(url)
- elif '?' not in filename:
- destname = filename
- elif url.endswith('?download'):
- destname = os.path.basename(url)
- destname = destname[0:len(destname)-len('?download')]
- else:
- exit("Can't compute filename for %s = %s" % (filename, url))
- archives.append({
+ exit("Can't compute filename for %s = %s" % (filename, url))
+ archives.append({
+ 'filename': filename,
'name': destname,
'size': file.size,
'md5': file.md5,
@@ -79,6 +77,19 @@ 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']))
for a in archives:
--
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