:py:mod:`dissect.target.tools.dump.state` ========================================= .. py:module:: dissect.target.tools.dump.state Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.tools.dump.state.Sink dissect.target.tools.dump.state.DumpState Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.tools.dump.state.create_state dissect.target.tools.dump.state.persisted_state dissect.target.tools.dump.state.load_state dissect.target.tools.dump.state.serialize_obj Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.target.tools.dump.state.log dissect.target.tools.dump.state.STATE_FILE_NAME dissect.target.tools.dump.state.PENDING_UPDATES_LIMIT .. py:data:: log .. py:data:: STATE_FILE_NAME :value: 'target-dump.state.json' .. py:data:: PENDING_UPDATES_LIMIT :value: 10 .. py:class:: Sink .. py:attribute:: target_path :type: str .. py:attribute:: func :type: str .. py:attribute:: path :type: pathlib.Path .. py:attribute:: is_dirty :type: bool :value: True .. py:attribute:: record_count :type: int :value: 0 .. py:attribute:: size_bytes :type: int :value: 0 .. py:method:: __post_init__() .. py:class:: DumpState .. py:property:: record_count :type: int .. py:property:: finished_sinks :type: list[Sink] .. py:property:: path :type: pathlib.Path .. py:attribute:: target_paths :type: list[str] .. py:attribute:: functions :type: list[str] .. py:attribute:: serialization :type: str .. py:attribute:: compression :type: str .. py:attribute:: start_time :type: datetime.datetime .. py:attribute:: last_update_time :type: datetime.datetime .. py:attribute:: sinks :type: list[Sink] .. py:attribute:: output_dir :type: Optional[pathlib.Path] .. py:attribute:: pending_updates_count :type: Optional[int] :value: 0 .. py:method:: get_state_path(output_dir: pathlib.Path) -> pathlib.Path :classmethod: .. py:method:: get_full_sink_path(sink: Sink) -> pathlib.Path .. py:method:: get_sink(path: pathlib.Path) -> Optional[Sink] .. py:method:: serialize() -> str Serialize state instance into a JSON formatted string .. py:method:: persist(fh: TextIO) -> None Write serialized state instance into profided `fh` byte stream, overwriting it from the beginning .. py:method:: mark_as_finished(target: dissect.target.Target, func: str) -> None Mark sinks that match provided `target` and `func` pair as not dirty. .. py:method:: 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). .. py:method:: update(stream_element, fp_position: int) -> None Update a sink instance for provided `stream_element`. .. py:method:: from_dict(state_dict: dict) -> DumpState :classmethod: Deserialize state instance from provided dict .. py:method:: from_path(output_dir: pathlib.Path) -> Optional[DumpState] :classmethod: Deserialize state instance from a file in the provided output directory path .. py:method:: get_invalid_sinks() -> list[Sink] Return sinks that have a mismatch between recorded size and a real file size .. py:method:: drop_invalid_sinks() -> None Remove sinks that have a mismatch between recorded size and a real file size from the list of sinks. .. py:method:: drop_dirty_sinks() -> None Drop sinks that are marked as "dirty" in the current state from the list of sinks .. py:function:: 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 .. py:function:: persisted_state(state: DumpState) -> Iterator[Callable] Return a context manager for persisting `DumpState` instance .. py:function:: load_state(output_dir: pathlib.Path) -> Optional[DumpState] Load persisted `DumpState` instance from provided `output_dir` path and perform sink validation. .. py:function:: serialize_obj(obj: Any) -> str JSON serializer for object types not serializable by `json` lib