Skip to content

Commit

Permalink
fix(yaffs): simplified storing collected data chunks and entries
Browse files Browse the repository at this point in the history
  • Loading branch information
martonilles authored and qkaiser committed Apr 17, 2023
1 parent 9cd1c8a commit 93afd1c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions unblob/handlers/filesystem/yaffs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io
import itertools
import os
from collections import defaultdict
from enum import IntEnum
from pathlib import Path
from typing import Iterable, List, Optional, Tuple
Expand Down Expand Up @@ -274,7 +275,7 @@ class YAFFSParser:

def __init__(self, file: File, config: Optional[YAFFSConfig] = None):
self.file_entries = Tree()
self.data_chunks = {}
self.data_chunks = defaultdict(list)
self.file = file
self._struct_parser = StructParser(C_DEFINITIONS)
self.end_offset = -1
Expand Down Expand Up @@ -322,14 +323,9 @@ def parse(self, store: bool = False): # noqa: C901,FBT001,FBT002
if not is_valid_header(header):
break

if not store:
continue
self.insert_entry(self.build_entry(header, data_chunk))
else:
if not store:
continue
if data_chunk.object_id not in self.data_chunks:
self.data_chunks[data_chunk.object_id] = []
if store:
self.insert_entry(self.build_entry(header, data_chunk))
elif store:
self.data_chunks[data_chunk.object_id].append(data_chunk)
self.end_offset = self.file.tell()

Expand Down

0 comments on commit 93afd1c

Please sign in to comment.