Skip to content

Issues with providing relative paths with backslashes on windows #324

Open
@FayyazulHassan

Description

@FayyazulHassan

I can see that on lines 1640-1643 there's a check to prevent relative paths. Unfortunately in the preceding lines the path string is split only by forward slashes thus resulting in relative paths with back slashes going undetected. As a result filter-repo considers no files to keep and deletes every file. As for why I was using relative directories with backslashes, that's the autocomplete windows supplies when hitting tab.

Since it looks like relative paths aren't something that want to be supported, maybe add a warning in the documentation? As this is something that only affects windows(or maybe there are other OSes that do this too...) and backslashes are legal file name characters in linux and macos a quick fix would be to add a check if the system is windows and then replace backslashes with forward slashes and then proceed with the rest of the processing as normal.

import platform

# In AppendFilter.__call__ and/or any other place 
# that depends on processing forward slashes as path delimiters.
if platform.system() == 'Windows':
    values.replace(b'\\', b'/')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions