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 --- subcmds/sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index ef023274..797fc403 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -19,7 +19,6 @@ import netrc from optparse import SUPPRESS_HELP import os import re -import shutil import socket import subprocess import sys @@ -73,6 +72,7 @@ from project import Project from project import RemoteSpec from command import Command, MirrorSafeCommand from error import RepoChangedException, GitError, ManifestParseError +import platform_utils from project import SyncBuffer from progress import Progress from wrapper import Wrapper @@ -473,7 +473,7 @@ later is required to fix a server side protocol bug. # working git repository around. There shouldn't be any git projects here, # so rmtree works. try: - shutil.rmtree(os.path.join(path, '.git')) + platform_utils.rmtree(os.path.join(path, '.git')) except OSError: print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) -- cgit v1.2.3-54-g00ecf