From a65adf74f990eeac0d90011476376c7239cb7af5 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2016 10:37:53 -0700 Subject: Workaround shutil.rmtree limitation on Windows By default, shutil.rmtree raises an exception when deleting readonly files on Windows. Replace all shutil.rmtree with platform_utils.rmtree, which adds an error handler to make files read-write when they can't be deleted. Change-Id: I9cfea9a7b3703fb16a82cf69331540c2c179ed53 --- project.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index de5c7915..ba18337b 100644 --- a/project.py +++ b/project.py @@ -2299,10 +2299,10 @@ class Project(object): print("Retrying clone after deleting %s" % self.gitdir, file=sys.stderr) try: - shutil.rmtree(os.path.realpath(self.gitdir)) + platform_utils.rmtree(os.path.realpath(self.gitdir)) if self.worktree and os.path.exists(os.path.realpath (self.worktree)): - shutil.rmtree(os.path.realpath(self.worktree)) + platform_utils.rmtree(os.path.realpath(self.worktree)) return self._InitGitDir(mirror_git=mirror_git, force_sync=False) except: raise e @@ -2344,9 +2344,9 @@ class Project(object): self.config.SetString('core.bare', None) except Exception: if init_obj_dir and os.path.exists(self.objdir): - shutil.rmtree(self.objdir) + platform_utils.rmtree(self.objdir) if init_git_dir and os.path.exists(self.gitdir): - shutil.rmtree(self.gitdir) + platform_utils.rmtree(self.gitdir) raise def _UpdateHooks(self): @@ -2516,7 +2516,7 @@ class Project(object): except GitError as e: if force_sync: try: - shutil.rmtree(dotgit) + platform_utils.rmtree(dotgit) return self._InitWorkTree(force_sync=False, submodules=submodules) except: raise e @@ -2536,7 +2536,7 @@ class Project(object): self._CopyAndLinkFiles() except Exception: if init_dotgit: - shutil.rmtree(dotgit) + platform_utils.rmtree(dotgit) raise def _gitdir_path(self, path): -- cgit v1.2.3-54-g00ecf