Author Kim.Gräsman
Recipients Kim.Gräsman
Date 2013-06-27.12:15:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372335321.1.0.479247042071.issue18314@psf.upfronthosting.co.za>
In-reply-to
Content
os.unlink currently raises a WindowsError (Access Denied) if I attempt to unlink an NTFS junction point.

It looks trivial to allow Py_DeleteFileW [1] to remove junction points as well as proper symbolic links, as far as I can tell.

For example, the ntfslink-python library [2] only checks if both FILE_ATTRIBUTE_DIRECTORY and FILE_ATTRIBUTE_REPARSE_POINT are set.

RemoveDirectoryW is documented to handle junction points transparently, so it should just be a matter of passing the path on if it's a junction point or a symbolic link.

My motivation for this is that I have used external tools to create junction points, and am now switching to symbolic links. When deleting a directory, I need to do:

    try:
        os.unlink(link_path)
    except WindowsError as detail:
        # BACKWARD COMPATIBILITY HACK
        if detail.winerror == 5:
            _delete_junction_point(link_path)
        else:
            raise

which is a little funky. It seems like os.unlink semantics work just as well for junction points, even if they can't be created with os.symlink.

Love it/hate it?

[1] http://hg.python.org/cpython/file/44f455e6163d/Modules/posixmodule.c#l4105
[2] https://github.com/Juntalis/ntfslink-python/blob/2f6ff903f9b22942de8aa93a32a3d817124f359e/ntfslink/internals/__init__.py#L32
History
Date User Action Args
2013-06-27 12:15:21Kim.Gräsmansetrecipients: + Kim.Gräsman
2013-06-27 12:15:21Kim.Gräsmansetmessageid: <1372335321.1.0.479247042071.issue18314@psf.upfronthosting.co.za>
2013-06-27 12:15:21Kim.Gräsmanlinkissue18314 messages
2013-06-27 12:15:20Kim.Gräsmancreate