Skip to content

Commit

Permalink
- Update Some Code
Browse files Browse the repository at this point in the history
Signed-off-by: ColdWindScholar <3590361911@qq.com>
  • Loading branch information
ColdWindScholar committed Aug 4, 2024
1 parent 03aaf64 commit d9a277b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import struct
import sys
import threading
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from multiprocessing import cpu_count

Expand Down Expand Up @@ -71,6 +72,7 @@ def run(self) -> bool:
self.payloadfile.seek(self.data_offset + int(operation.get("2", 0)))
operations.append({"data_offset": self.payloadfile.tell(), "operation": operation,
"data_length": int(operation.get("3", 0))})

partitions_with_ops.append({"name": partition.get('1'), "operations": operations})

self.payloadfile.close()
Expand Down Expand Up @@ -125,7 +127,7 @@ def data_for_op(self, operation, out_file, old_file):
dst_extents = [op.get('6')]
else:
dst_extents = op.get('6')
out_file.seek(int(dst_extents[0].get('1')) * self.block_size)
out_file.seek(int(dst_extents[0].get('1', 0)) * self.block_size)
while processed_len < data_length:
data = payloadfile.read(buffsize)
processed_len += len(data)
Expand All @@ -141,7 +143,7 @@ def data_for_op(self, operation, out_file, old_file):
dst_extents = [op.get('6')]
else:
dst_extents = op.get('6')
out_file.seek(int(dst_extents[0].get('1')) * self.block_size)
out_file.seek(int(dst_extents[0].get('1', 0)) * self.block_size)
while processed_len < data_length:
data = payloadfile.read(buffsize)
processed_len += len(data)
Expand All @@ -156,7 +158,7 @@ def data_for_op(self, operation, out_file, old_file):
dst_extents = [op.get('6')]
else:
dst_extents = op.get('6')
out_file.seek(int(dst_extents[0].get('1')) * self.block_size)
out_file.seek(int(dst_extents[0].get('1', 0)) * self.block_size)
while processed_len < data_length:
data = payloadfile.read(buffsize)
processed_len += len(data)
Expand All @@ -170,14 +172,14 @@ def data_for_op(self, operation, out_file, old_file):
dst_extents = [op.get('6')]
else:
dst_extents = op.get('6')
out_file.seek(int(dst_extents[0].get('1')) * self.block_size)
out_file.seek(int(dst_extents[0].get('1', 0)) * self.block_size)
if isinstance(op.get('4'), dict):
src_extents = [op.get('4')]
else:
src_extents = op.get('4')
for ext in src_extents:
old_file.seek(int(ext.get('1')) * self.block_size)
data_length = int(ext.get('2')) * self.block_size
old_file.seek(int(ext.get('1', 0)) * self.block_size)
data_length = int(ext.get('2', 0)) * self.block_size
while processed_len < data_length:
data = old_file.read(buffsize)
processed_len += len(data)
Expand All @@ -189,8 +191,8 @@ def data_for_op(self, operation, out_file, old_file):
else:
dst_extents = op.get('6')
for ext in dst_extents:
out_file.seek(int(ext.get('1')) * self.block_size)
data_length = int(ext.get('2')) * self.block_size
out_file.seek(int(ext.get('1', 0)) * self.block_size)
data_length = int(ext.get('2', 0)) * self.block_size
while processed_len < data_length:
data = bytes(min(data_length - processed_len, buffsize))
out_file.write(data)
Expand Down

0 comments on commit d9a277b

Please sign in to comment.