示例#1
0
def binaryencode(repo, metadataids):
    """encode snapshot metadata into a binary CBOR stream

    format (CBOR-encoded):
    {
        "metadatafiles": {
            <metadata oid>: <binary metadata content>,
            . . .
        },
        "auxfiles": {
            <file oid>: <binary file content>,
            . . .
        }
    }
    """

    metadataauxfilesinfo = set()
    bundlepartdict = {"metadatafiles": {}, "auxfiles": {}}
    store = repo.svfs.snapshotstore
    # store the metadata files
    for metadataid in metadataids:
        data = store.read(metadataid)
        bundlepartdict["metadatafiles"][metadataid] = data
        snapmetadata = metadata.snapshotmetadata.deserialize(data)
        metadataauxfilesinfo.update(snapmetadata.getauxfilesinfo())
    # store files that are mentioned in metadata
    for fileid in metadataauxfilesinfo:
        bundlepartdict["auxfiles"][fileid] = store.read(fileid)
    return "".join(cborutil.streamencode(bundlepartdict))
示例#2
0
文件: metadata.py 项目: xmonader/eden
 def serialize(self):
     return "".join(cborutil.streamencode(self.todict()))