Skip to content

Commit

Permalink
Merge pull request #512 from bongbui321/fix_sparse
Browse files Browse the repository at this point in the history
fix sparse get size()
  • Loading branch information
bkerler authored Mar 5, 2024
2 parents fa58a5a + 2e2ab70 commit 8f606dd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions edlclient/Library/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,30 @@ def get_chunk_size(self):
chunk_sz = header[2]
total_sz = header[3]
data_sz = total_sz - 12

if chunk_type == 0xCAC1:
if data_sz != (chunk_sz * self.blk_sz):
self.error(
"Raw chunk input size (%u) does not match output size (%u)" % (data_sz, chunk_sz * self.blk_sz))
return -1
else:
self.rf.seek(self.rf.tell() + chunk_sz * self.blk_sz)
self.rf.seek(self.rf.tell() + data_sz)
return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC2:
if data_sz != 4:
self.error("Fill chunk should have 4 bytes of fill, but this has %u" % data_sz)
return -1
else:
return chunk_sz * self.blk_sz // 4
self.rf.seek(self.rf.tell() + data_sz)
return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC3:
return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC4:
if data_sz != 4:
self.error("CRC32 chunk should have 4 bytes of CRC, but this has %u" % data_sz)
return -1
else:
self.rf.seek(self.rf.tell() + 4)
self.rf.seek(self.rf.tell() + data_sz)
return 0
else:
self.debug("Unknown chunk type 0x%04X" % chunk_type)
Expand Down

0 comments on commit 8f606dd

Please sign in to comment.