Skip to content

Commit 829704d

Browse files
committed
fix(yaffs): improve perfs by not storing data in parsing mode only.
1 parent bd20e0d commit 829704d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

unblob/handlers/filesystem/yaffs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,8 @@ def get_chunks(self, object_id: int) -> Iterable[YAFFSChunk]:
299299
def init_tree(self):
300300
return
301301

302-
def parse(self):
302+
def parse(self, store: bool = False): # noqa: C901,FBT001,FBT002
303303
self.init_tree()
304-
305304
for offset, page, spare in iterate_over_file(self.file, self.config):
306305
try:
307306
data_chunk = self.build_chunk(
@@ -326,9 +325,12 @@ def parse(self):
326325
if not is_valid_header(header):
327326
break
328327

329-
entry = self.build_entry(header, data_chunk)
330-
self.insert_entry(entry)
328+
if not store:
329+
continue
330+
self.insert_entry(self.build_entry(header, data_chunk))
331331
else:
332+
if not store:
333+
continue
332334
if data_chunk.object_id not in self.data_chunks:
333335
self.data_chunks[data_chunk.object_id] = []
334336
self.data_chunks[data_chunk.object_id].append(data_chunk)
@@ -732,7 +734,7 @@ class YAFFSExtractor(Extractor):
732734
def extract(self, inpath: Path, outdir: Path):
733735
infile = File.from_path(inpath)
734736
parser = instantiate_parser(infile)
735-
parser.parse()
737+
parser.parse(store=True)
736738
parser.extract(outdir)
737739

738740

0 commit comments

Comments
 (0)