Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with lib_deps option // Resolve #3664

This commit is contained in:
Ivan Kravets
2020-09-12 23:20:46 +03:00
parent 7bc170a53e
commit 687c339f20
2 changed files with 10 additions and 6 deletions

View File

@ -11,7 +11,8 @@ PlatformIO Core 5
5.0.2 (2020-09-??)
~~~~~~~~~~~~~~~~~~
- Fixed an issue with "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
- Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps <https://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option (`issue #3664 <https://github.com/platformio/platformio-core/issues/3664>`_)
- Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~

View File

@ -152,7 +152,10 @@ class PackageManagerInstallMixin(object):
return self._install_tmp_pkg(pkg_item)
finally:
if os.path.isdir(tmp_dir):
fs.rmtree(tmp_dir)
try:
shutil.rmtree(tmp_dir)
except: # pylint: disable=bare-except
pass
def _install_tmp_pkg(self, tmp_pkg):
assert isinstance(tmp_pkg, PackageItem)
@ -213,10 +216,10 @@ class PackageManagerInstallMixin(object):
# move existing into the new place
pkg_dir = os.path.join(self.package_dir, target_dirname)
_cleanup_dir(pkg_dir)
shutil.move(dst_pkg.path, pkg_dir)
shutil.copytree(dst_pkg.path, pkg_dir, symlinks=True)
# move new source to the destination location
_cleanup_dir(dst_pkg.path)
shutil.move(tmp_pkg.path, dst_pkg.path)
shutil.copytree(tmp_pkg.path, dst_pkg.path, symlinks=True)
return PackageItem(dst_pkg.path)
if action == "detach-new":
@ -233,10 +236,10 @@ class PackageManagerInstallMixin(object):
)
pkg_dir = os.path.join(self.package_dir, target_dirname)
_cleanup_dir(pkg_dir)
shutil.move(tmp_pkg.path, pkg_dir)
shutil.copytree(tmp_pkg.path, pkg_dir, symlinks=True)
return PackageItem(pkg_dir)
# otherwise, overwrite existing
_cleanup_dir(dst_pkg.path)
shutil.move(tmp_pkg.path, dst_pkg.path)
shutil.copytree(tmp_pkg.path, dst_pkg.path, symlinks=True)
return PackageItem(dst_pkg.path)