Dulwich.io dulwich / 2ff2da3
Fix swift tests. Jelmer Vernooń≥ 2 months ago
2 changed file(s) with 12 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
649649 self.pack_dir = posixpath.join(OBJECTDIR, PACKDIR)
650650 self._alternates = None
651651
652 @property
653 def packs(self):
654 """List with pack objects."""
655 if not self._pack_cache:
656 self._update_pack_cache()
657 return self._pack_cache.values()
658
659652 def _update_pack_cache(self):
660 for pack in self._load_packs():
661 self._pack_cache[pack._basename] = pack
653 objects = self.scon.get_container_objects()
654 pack_files = [o['name'].replace(".pack", "")
655 for o in objects if o['name'].endswith(".pack")]
656 ret = []
657 for basename in pack_files:
658 pack = SwiftPack(basename, scon=self.scon)
659 self._pack_cache[basename] = pack
660 ret.append(pack)
661 return ret
662662
663663 def _iter_loose_objects(self):
664664 """Loose objects are not supported by this repository
678678 def find_missing_objects(self, *args, **kwargs):
679679 kwargs['concurrency'] = self.scon.concurrency
680680 return PackInfoMissingObjectFinder(self, *args, **kwargs)
681
682 def _load_packs(self):
683 """Load all packs from Swift
684
685 :return: a list of `SwiftPack` instances
686 """
687 objects = self.scon.get_container_objects()
688 pack_files = [o['name'].replace(".pack", "")
689 for o in objects if o['name'].endswith(".pack")]
690 return [SwiftPack(pack, scon=self.scon) for pack in pack_files]
691681
692682 def pack_info_get(self, sha):
693683 for pack in self.packs:
744734 index.close()
745735 final_pack = SwiftPack(basename, scon=self.scon)
746736 final_pack.check_length_and_checksum()
747 self._add_known_pack(basename, final_pack)
737 self._add_cached_pack(basename, final_pack)
748738 return final_pack
749739 else:
750740 return None
837827 # Add the pack to the store and return it.
838828 final_pack = SwiftPack(pack_base_name, scon=self.scon)
839829 final_pack.check_length_and_checksum()
840 self._add_known_pack(pack_base_name, final_pack)
830 self._add_cached_pack(pack_base_name, final_pack)
841831 return final_pack
842832
843833
285285 'fakerepo/objects/pack/pack-'+'2'*40+'.info': ''}
286286 fsc = FakeSwiftConnector('fakerepo', conf=self.conf, store=store)
287287 sos = swift.SwiftObjectStore(fsc)
288 packs = sos._load_packs()
288 packs = sos.packs
289289 self.assertEqual(len(packs), 2)
290290 for pack in packs:
291291 self.assertTrue(isinstance(pack, swift.SwiftPack))