Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows with_rw-directory TC helper fails to delete repos #32

Open
ankostis opened this issue Sep 27, 2016 · 1 comment
Open

Windows with_rw-directory TC helper fails to delete repos #32

ankostis opened this issue Sep 27, 2016 · 1 comment

Comments

@ankostis
Copy link
Contributor

On Windows, os.rmtree cannot not remove directories with read-only files; such are the git db directories.

The fix is something like this:

           ...
        finally:
            # Need to collect here to be sure all handles have been closed. It appears
            # a windows-only issue. In fact things should be deleted, as well as
            # memory maps closed, once objects go out of scope. For some reason
            # though this is not the case here unless we collect explicitly.
            if not keep:
                gc.collect()

                # From http://stackoverflow.com/a/4829285/548792
                def on_rm_error(func, path, exc_info):
                    import stat
                    os.chmod(path, stat.S_IWRITE)
                    func(path)

                shutil.rmtree(path, onerror=on_rm_error)
@Byron
Copy link
Member

Byron commented Oct 1, 2016

I assume that this one could be fixed in conjunction with this PR ?
In any case, thanks for reporting, it's good to keep track of the issue and a possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants