649 | 649 |
self.pack_dir = posixpath.join(OBJECTDIR, PACKDIR)
|
650 | 650 |
self._alternates = None
|
651 | 651 |
|
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 | |
|
659 | 652 |
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
|
662 | 662 |
|
663 | 663 |
def _iter_loose_objects(self):
|
664 | 664 |
"""Loose objects are not supported by this repository
|
|
678 | 678 |
def find_missing_objects(self, *args, **kwargs):
|
679 | 679 |
kwargs['concurrency'] = self.scon.concurrency
|
680 | 680 |
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]
|
691 | 681 |
|
692 | 682 |
def pack_info_get(self, sha):
|
693 | 683 |
for pack in self.packs:
|
|
744 | 734 |
index.close()
|
745 | 735 |
final_pack = SwiftPack(basename, scon=self.scon)
|
746 | 736 |
final_pack.check_length_and_checksum()
|
747 | |
self._add_known_pack(basename, final_pack)
|
|
737 |
self._add_cached_pack(basename, final_pack)
|
748 | 738 |
return final_pack
|
749 | 739 |
else:
|
750 | 740 |
return None
|
|
837 | 827 |
# Add the pack to the store and return it.
|
838 | 828 |
final_pack = SwiftPack(pack_base_name, scon=self.scon)
|
839 | 829 |
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)
|
841 | 831 |
return final_pack
|
842 | 832 |
|
843 | 833 |
|