From: Avery Pennarun Date: Fri, 5 Feb 2010 00:26:17 +0000 (-0500) Subject: bup-server: revert to non-midx indexes when suggesting a pack. X-Git-Tag: bup-0.08a~2 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8205ab3591fcb60f4922d1d72934c75cb3865d2;p=bup.git bup-server: revert to non-midx indexes when suggesting a pack. Currently midx files can't tell you *which* index contains a particular hash, just that *one* of them does. So bup-server was barfing when it expected MultiPackIndex.exists() to return a pack name, and was getting a .midx file instead. We could have loosened the assertion and allowed the server to suggest a .midx file... but those can be huge, and it defeats the purpose of only suggesting the minimal set of packs so that lightweight clients aren't overwhelmed. --- diff --git a/cmd-server.py b/cmd-server.py index 5ca8f36..7cc78a3 100755 --- a/cmd-server.py +++ b/cmd-server.py @@ -75,6 +75,20 @@ def receive_objects(conn, junk): (type, content) = git._decode_packobj(buf) sha = git.calc_hash(type, content) oldpack = w.exists(sha) + if oldpack and (oldpack == True or oldpack.endswith('.midx')): + # FIXME: we shouldn't really have to know about midx files + # at this layer. But exists() on a midx doesn't return the + # packname (since it doesn't know)... probably we should just + # fix that deficiency of midx files eventually, although it'll + # make the files bigger. This method is certainly not very + # efficient. + w.objcache.refresh(skip_midx = True, forget_packs = True) + oldpack = w.objcache.exists(sha) + log('new suggestion: %r\n' % oldpack) + assert(oldpack) + assert(oldpack != True) + assert(not oldpack.endswith('.midx')) + w.objcache.refresh(skip_midx = False) if oldpack: assert(oldpack.endswith('.idx')) (dir,name) = os.path.split(oldpack) diff --git a/git.py b/git.py index 23c0d46..71ca32d 100644 --- a/git.py +++ b/git.py @@ -230,11 +230,13 @@ class MultiPackIndex: return p.name return None - def refresh(self): - global ignore_midx + def refresh(self, skip_midx = False, forget_packs = False): + if forget_packs: + self.packs = [] + skip_midx = skip_midx or ignore_midx d = dict([(p.name, 1) for p in self.packs]) if os.path.exists(self.dir): - if not ignore_midx: + if not skip_midx: midxl = [] for f in os.listdir(self.dir): full = os.path.join(self.dir, f)