'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.'

def add_thin_pack(self, read_all, read_some):

    (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)
