sha = git.calc_hash(type, content)
oldpack = w.exists(sha)
# FIXME: we only suggest a single index per cycle, because the client
- # is currently dumb to download more than one per cycle anyway.
+ # is currently too dumb to download more than one per cycle anyway.
# Actually we should fix the client, but this is a minor optimization
# on the server side.
if not suggested and \
# 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)
- oldpack = w.objcache.exists(sha)
+ oldpack = w.objcache.packname_containing(sha)
debug2('new suggestion: %r\n' % oldpack)
assert(oldpack)
assert(oldpack != True)
assert(not oldpack.endswith('.midx'))
- w.objcache.refresh(skip_midx = False)
+ w.objcache.refresh()
if not suggested and oldpack:
assert(oldpack.endswith('.idx'))
(dir,name) = os.path.split(oldpack)
debug1('PackIdxList: using %d index%s.\n'
% (len(self.packs), len(self.packs)!=1 and 'es' or ''))
+ def packname_containing(self, hash):
+ # figure out which pack contains a given hash.
+ # FIXME: if the midx file format would just *store* this information,
+ # we could calculate it a lot more efficiently. But it's not needed
+ # often, so let's do it like this.
+ for f in os.listdir(self.dir):
+ if f.endswith('.idx'):
+ full = os.path.join(self.dir, f)
+ ix = open_idx(full)
+ if ix.exists(hash):
+ return full
+
def add(self, hash):
"""Insert an additional object in the list."""
self.also[hash] = 1