From 5bdfb1ef8405a14186637785014aa32337867df5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 15 Oct 2008 19:28:30 +0000 Subject: Checkpoint: s/glider/thandy/; s/sexp/json/ git-svn-id: file:///home/or/svnrepo/updater/trunk@17109 55e972cd-5a19-0410-ae62-a4d7a52db4cd --- lib/thandy/formats.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/thandy/formats.py') diff --git a/lib/thandy/formats.py b/lib/thandy/formats.py index 08d7a7f..c44c9cf 100644 --- a/lib/thandy/formats.py +++ b/lib/thandy/formats.py @@ -670,6 +670,15 @@ def makeBundleObj(config_fname, getPackage): def versionIsNewer(v1, v2): return v1 > v2 +def getBundleKey(bundlePath): + """ + >>> getBundleKey("/bundleinfo/tor-browser/win32/some-file-name.txt") + '/bundleinfo/tor-browser/win32/' + """ + # No, we can't use "os.path.directory." That isn't os-independent. + idx = bundlePath.rindex("/") + return bundlePath[:idx+1] + def makeTimestampObj(mirrorlist_obj, keylist_obj, bundle_objs): result = { '_type' : 'Timestamp', @@ -680,11 +689,11 @@ def makeTimestampObj(mirrorlist_obj, keylist_obj, formatHash(getDigest(keylist_obj)) ] result['b'] = bundles = {} for bundle in bundle_objs: - name = bundle['name'] + k = getBundleKey(bundle['location']) v = bundle['version'] entry = [ v, bundle['location'], bundle['at'], formatHash(getDigest(bundle)) ] - if not bundles.has_key(name) or versionIsNewer(v, bundles[name][0]): - bundles[name] = entry + if not bundles.has_key(k) or versionIsNewer(v, bundles[k]['version']): + bundles[k] = entry TIMESTAMP_SCHEMA.checkMatch(result) -- cgit v1.2.3