From 95850a79264be62948dccc8987dce94eecc32c45 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 4 Mar 2007 13:27:24 +0000 Subject: [PATCH] Include the size of symlinks in the unoptimised count, and display the size of the manifest files too. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/trunk/0launch@1578 9f8c893c-44ee-0310-b757-c8ca8341c71e --- zeroinstall/zerostore/cli.py | 4 ++-- zeroinstall/zerostore/optimise.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/zeroinstall/zerostore/cli.py b/zeroinstall/zerostore/cli.py index d46e96e..e06427a 100644 --- a/zeroinstall/zerostore/cli.py +++ b/zeroinstall/zerostore/cli.py @@ -111,8 +111,8 @@ def do_optimise(args): return '%.1f %s' % (size, unit) import optimise - uniq_size, dup_size, already_linked = optimise.optimise(cache_dir) - print "Original size :", _pretty_size(uniq_size + dup_size) + uniq_size, dup_size, already_linked, man_size = optimise.optimise(cache_dir) + print "Original size :", _pretty_size(uniq_size + dup_size) + " (excluding the %s of manifests)" % _pretty_size(man_size) print "Already saved :", _pretty_size(already_linked) if dup_size == 0: print "No duplicates found; no changes made." diff --git a/zeroinstall/zerostore/optimise.py b/zeroinstall/zerostore/optimise.py index cf2e83e..70400a2 100644 --- a/zeroinstall/zerostore/optimise.py +++ b/zeroinstall/zerostore/optimise.py @@ -38,11 +38,11 @@ def optimise(impl_dir): @type impl_dir: str @param verbose: display progress messages @type verbose: bool - @return: (unique bytes, duplicated bytes, already_linked) - @rtype: (int, int, int)""" + @return: (unique bytes, duplicated bytes, already linked, manifest size) + @rtype: (int, int, int, int)""" first_copy = {} # TypeDigest -> Path - dup_size = uniq_size = already_linked = 0 + dup_size = uniq_size = already_linked = man_size = 0 import random @@ -64,6 +64,8 @@ def optimise(impl_dir): warn("Failed to read manifest file '%s': %s", manifest_path, str(ex)) continue + man_size += os.path.getsize(manifest_path) + alg = impl.split('=', 1)[0] if alg == 'sha1': continue @@ -75,7 +77,12 @@ def optimise(impl_dir): dir = path[1:-1] # Strip slash and newline continue - if line[0] not in "FX": continue + if line[0] == "S": + type, digest, size, rest = line.split(' ', 3) + uniq_size += long(size) + continue + + assert line[0] in "FX" type, digest, mtime, size, path = line.split(' ', 4) path = path[:-1] # Strip newline @@ -96,4 +103,4 @@ def optimise(impl_dir): else: first_copy[key] = loc_path uniq_size += size - return (uniq_size, dup_size, already_linked) + return (uniq_size, dup_size, already_linked, man_size) -- 2.11.4.GIT