Skip to content

Commit

Permalink
bup-server: revert to non-midx indexes when suggesting a pack.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apenwarr committed Feb 5, 2010
1 parent ed13749 commit e8205ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 14 additions & 0 deletions cmd-server.py
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions git.py
Expand Up @@ -230,11 +230,13 @@ def exists(self, hash):
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)
Expand Down

0 comments on commit e8205ab

Please sign in to comment.