示例#1
0
    def add_thin_pack(self, read_all, read_some):
        """Add a new thin pack to this object store.

        Thin packs are packs that contain deltas with parents that exist outside
        the pack. They should never be placed in the object store directly, and
        always indexed and completed as they are copied.

        :param read_all: Read function that blocks until the number of requested
            bytes are read.
        :param read_some: Read function that returns at least one byte, but may
            not return the number of bytes requested.
        :return: A Pack object pointing at the now-completed thin pack in the
            objects/pack directory.
        """
        fd, path = tempfile.mkstemp(dir=self.path, prefix='tmp_pack_')
        f = os.fdopen(fd, 'w+b')

        try:
            indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
            copier = PackStreamCopier(read_all, read_some, f,
                                      delta_iter=indexer)
            copier.verify()
            return self._complete_thin_pack(f, path, copier, indexer)
        finally:
            f.close()
    def add_thin_pack(self, read_all, read_some):
        """Add a new thin pack to this object store.

        Thin packs are packs that contain deltas with parents that exist
        outside the pack. Because this object store doesn't support packs, we
        extract and add the individual objects.

        :param read_all: Read function that blocks until the number of
            requested bytes are read.
        :param read_some: Read function that returns at least one byte, but may
            not return the number of bytes requested.
        """
        f, commit, abort = self.add_pack()
        try:
            indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
            copier = PackStreamCopier(read_all,
                                      read_some,
                                      f,
                                      delta_iter=indexer)
            copier.verify()
            self._complete_thin_pack(f, indexer)
        except BaseException:
            abort()
            raise
        else:
            commit()
示例#3
0
    def add_thin_pack(self, read_all, read_some):
        """Add a new thin pack to this object store.

        Thin packs are packs that contain deltas with parents that exist outside
        the pack. They should never be placed in the object store directly, and
        always indexed and completed as they are copied.

        :param read_all: Read function that blocks until the number of requested
            bytes are read.
        :param read_some: Read function that returns at least one byte, but may
            not return the number of bytes requested.
        :return: A Pack object pointing at the now-completed thin pack in the
            objects/pack directory.
        """
        fd, path = tempfile.mkstemp(dir=self.path.decode(
            sys.getfilesystemencoding()),
                                    prefix='tmp_pack_')
        path = path.encode(sys.getfilesystemencoding())
        with os.fdopen(fd, 'w+b') as f:
            indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
            copier = PackStreamCopier(read_all,
                                      read_some,
                                      f,
                                      delta_iter=indexer)
            copier.verify()
            return self._complete_thin_pack(f, path, copier, indexer)
示例#4
0
 def add_thin_pack(self, read_all, read_some):
     f = StringIO()
     indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
     copier = PackStreamCopier(read_all, read_some, f, delta_iter=indexer)
     copier.verify()
     pack_store = PackStore(repository=self.REPO)
     final_pack = Pack.from_thinpack(pack_store, f, indexer, resolve_ext_ref=self.get_raw)
     self._add_known_pack(final_pack)
示例#5
0
 def add_thin_pack(self, read_all, read_some):
     f = StringIO()
     indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
     copier = PackStreamCopier(read_all, read_some, f, delta_iter=indexer)
     copier.verify()
     pack_store = PackStore(repository=self.REPO)
     final_pack = Pack.from_thinpack(pack_store,
                                     f,
                                     indexer,
                                     resolve_ext_ref=self.get_raw)
     self._add_known_pack(final_pack)
示例#6
0
 def add_thin_pack(self, read_all, read_some):
     f, commit, abort = self.add_pack()
     try:
         indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
         copier = PackStreamCopier(read_all,
                                   read_some,
                                   f,
                                   delta_iter=indexer)
         copier.verify()
         #self._complete_thin_pack(f, indexer)
     except:
         abort()
         raise
     else:
         commit()
示例#7
0
    def add_thin_pack(self, read_all, read_some):
        """Read a thin pack

        Read it from a stream and complete it in a temporary file.
        Then the pack and the corresponding index file are uploaded to Swift.
        """
        fd, path = tempfile.mkstemp(prefix='tmp_pack_')
        f = os.fdopen(fd, 'w+b')
        try:
            indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
            copier = PackStreamCopier(read_all, read_some, f,
                                      delta_iter=indexer)
            copier.verify()
            return self._complete_thin_pack(f, path, copier, indexer)
        finally:
            f.close()
            os.unlink(path)
示例#8
0
    def add_thin_pack(self, read_all, read_some):
        """Add a new thin pack to this object store.

        Thin packs are packs that contain deltas with parents that exist outside
        the pack. Because this object store doesn't support packs, we extract
        and add the individual objects.

        :param read_all: Read function that blocks until the number of requested
            bytes are read.
        :param read_some: Read function that returns at least one byte, but may
            not return the number of bytes requested.
        """
        f, commit = self.add_pack()
        indexer = PackIndexer(f, resolve_ext_ref=self.get_raw)
        copier = PackStreamCopier(read_all, read_some, f, delta_iter=indexer)
        copier.verify()
        self._complete_thin_pack(f, indexer)
        commit()