dissect.target.tools.dump.state

Module Contents

Classes

Functions

create_state

Create a DumpState instance with provided properties

persisted_state

Return a context manager for persisting DumpState instance

load_state

Load persisted DumpState instance from provided output_dir path

serialize_obj

JSON serializer for object types not serializable by json lib

Attributes

dissect.target.tools.dump.state.log
dissect.target.tools.dump.state.STATE_FILE_NAME = 'target-dump.state.json'
dissect.target.tools.dump.state.PENDING_UPDATES_LIMIT = 10
class dissect.target.tools.dump.state.Sink
target_path: str
func: str
path: pathlib.Path
is_dirty: bool = True
record_count: int = 0
size_bytes: int = 0
__post_init__()
class dissect.target.tools.dump.state.DumpState
target_paths: list[str]
functions: list[str]
serialization: str
compression: str
start_time: datetime.datetime
last_update_time: datetime.datetime
sinks: list[Sink]
output_dir: pathlib.Path | None = None
pending_updates_count: int | None = 0
property record_count: int
property finished_sinks: list[Sink]
property path: pathlib.Path
classmethod get_state_path(output_dir: pathlib.Path) pathlib.Path
get_full_sink_path(sink: Sink) pathlib.Path
get_sink(path: pathlib.Path) Sink | None
serialize() str

Serialize state instance into a JSON formatted string

persist(fh: TextIO) None

Write serialized state instance into profided fh byte stream, overwriting it from the beginning

mark_as_finished(target: dissect.target.Target, func: str) None

Mark sinks that match provided target and func pair as not dirty.

create_sink(sink_path: pathlib.Path, stream_element) Sink

Create a sink instance for provided sink_path and stream_element (from which target and func properties are used).

update(stream_element, fp_position: int) None

Update a sink instance for provided stream_element.

classmethod from_dict(state_dict: dict) DumpState

Deserialize state instance from provided dict

classmethod from_path(output_dir: pathlib.Path) DumpState | None

Deserialize state instance from a file in the provided output directory path

get_invalid_sinks() list[Sink]

Return sinks that have a mismatch between recorded size and a real file size

drop_invalid_sinks() None

Remove sinks that have a mismatch between recorded size and a real file size from the list of sinks.

drop_dirty_sinks() None

Drop sinks that are marked as “dirty” in the current state from the list of sinks

dissect.target.tools.dump.state.create_state(*, output_dir: pathlib.Path, target_paths: list[str], functions: list[str], serialization: dissect.target.tools.dump.utils.Serialization, compression: dissect.target.tools.dump.utils.Compression = None) DumpState

Create a DumpState instance with provided properties

dissect.target.tools.dump.state.persisted_state(state: DumpState) Iterator[Callable]

Return a context manager for persisting DumpState instance

dissect.target.tools.dump.state.load_state(output_dir: pathlib.Path) DumpState | None

Load persisted DumpState instance from provided output_dir path and perform sink validation.

dissect.target.tools.dump.state.serialize_obj(obj: Any) str

JSON serializer for object types not serializable by json lib