Skip to content

TargetPath issue when using samefile with a stringpath on different python versions #1289

@Miauwkeru

Description

@Miauwkeru

I found this when reviewing fox-it/acquire#255. Path.samefile doesn't function as intended on some of the TargetPath implementations.

These are my findings as of now using TargetPath.samefile(string_path)

  • python3.9
    During the samefile call it raises an AttributeError of it missing a _accessor property inside the TargetPath

    occurs during a Path.samefile, it attempts to stat both files. This is the TargetPath and the stringy path. However, when it attempts to stat the TargetPath it misses the _accessor that is used inside TargetPath

    *Note*
    This is also an issue when using TargetPath.samefile(TargetPath)

  • python3.10
    When calling samefile with a string path it attempts to stat the string path with self._accessor.stat('/str/of/path'). However, in the stat of TargetPath 3.10 it assumes the path passed is a TargetPath object. Then it attempts to use a get call on the string which doesn't exist

  • python3.11
    When calling samefile on python 3.11 we get the following error:

    TypeError: invalid PureDissectPath initialization: missing filesystem, got ('/vmfs/volumes/a8904c52-004e297f-9598-eb765dc56934',) (this might be a bug, please report)

    In this case samefile attempts to create a new PureDissectPath class. During this process it runs PureDissectPath._from_parts where it expects the first argument to be a Filesystem but instead it receives the string path, and it crashes.

Didn't find an issue with python 3.12 or python 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcoreRelated to a core component of dissect.target

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions