def applyDiff(self, base_chunk, diff): result, target = xdelta3.xd3_decode_memory(diff, base_chunk.get(), self.MAX_SIZE) if result: raise DiffException("Error: '{}'".format(os.strerror(result))) return storage.Chunk(target)
def Decode(self, ignore1, ignore2, ignore3): r2, data1 = xdelta3.xd3_decode_memory(self.encoded, None, len(self.target_data)) if r2 != 0: raise CommandError('memory', 'decode failed: %s' % r1) #end self.decoded = data1
def merge_data(source_data, overlay_data, buf_len): if len(source_data) == 0 or len(overlay_data) == 0: raise IOError("[Error] Not valid data length: %d, %d" % (len(source_data), len(overlay_data))) result, recover = xdelta3.xd3_decode_memory(overlay_data, source_data, buf_len) if result != 0: raise IOError("Error while xdelta3 : %d" % result) return recover
assert result == 28 assert ignore == None print 'encode: no source ...' result, zdata = xdelta3.xd3_encode_memory(target, None, 50) assert result == 0 assert len(zdata) > len(patch) print 'encode: no input ...' result, ignore = xdelta3.xd3_encode_memory(None, None, 50) assert result != 0 print 'decode: basic ...' result, target1 = xdelta3.xd3_decode_memory(patch, source, len(target)) assert result == 0 assert len(target1) == len(target) assert target1 == target print 'decode: out of space ...' result, ignore = xdelta3.xd3_decode_memory(patch, source, len(target) - 1) assert result == 28 assert ignore == None print 'decode: zero space ...' result, ignore = xdelta3.xd3_decode_memory(patch, source, 0) assert result == 28