Copy and remove cloned package instead of moving // Resolve #2844, Resolve #3328

On Windows, it’s not possible to move a file which is used by another
process (e.g. Git extension in VSCode)
This commit is contained in:
Valerii Koval
2020-05-20 21:32:55 +03:00
parent bdd57bf356
commit 735435306d

View File

@ -582,7 +582,11 @@ class PkgInstallerMixin(object):
# remove previous/not-satisfied package # remove previous/not-satisfied package
if isdir(pkg_dir): if isdir(pkg_dir):
fs.rmtree(pkg_dir) fs.rmtree(pkg_dir)
shutil.move(tmp_dir, pkg_dir) shutil.copytree(tmp_dir, pkg_dir, symlinks=True)
try:
shutil.rmtree(tmp_dir)
except: # pylint: disable=bare-except
pass
assert isdir(pkg_dir) assert isdir(pkg_dir)
self.cache_reset() self.cache_reset()
return pkg_dir return pkg_dir