Skip to content

Commit

Permalink
Move file write to decode
Browse files Browse the repository at this point in the history
 For seek to dst_extents(not plain write)
  • Loading branch information
vm03 committed Aug 20, 2019
1 parent 6ee284b commit cee019e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions payload_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ def data_for_op(op):

if op.type == op.REPLACE_XZ:
dec = lzma.LZMADecompressor()
data = dec.decompress(data)
data = dec.decompress(data)
out_file.seek(op.dst_extents[0].start_block*block_size)
out_file.write(data)
elif op.type == op.REPLACE_BZ:
dec = bz2.BZ2Decompressor()
data = dec.decompress(data)
data = dec.decompress(data)
out_file.seek(op.dst_extents[0].start_block*block_size)
out_file.write(data)
else:
print ("Unsupported type = %d" % op.type)

return data

Expand All @@ -53,10 +59,6 @@ def dump_part(part):

for op in part.operations:
data = data_for_op(op)
h.update(data)
out_file.write(data)

# assert h.digest() == part.new_partition_info.hash, 'partition hash mismatch'

p = open(sys.argv[1], 'rb')

Expand Down

0 comments on commit cee019e

Please sign in to comment.