From 2370e16f1bb024759babf3b0c09a891024e2dd4f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 19 Sep 2020 19:29:51 +0300 Subject: [PATCH] Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses // Resolve #3677 --- HISTORY.rst | 1 + platformio/package/manager/base.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index a57d1ab8..9b4bbf31 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,6 +14,7 @@ PlatformIO Core 5 - Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps `__ option (`issue #3664 `_) - Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 `_) - Fixed an issue with GCC linker when "native" dev-platform is used in pair with library dependencies (`issue #3669 `_) +- Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 `_) 5.0.1 (2020-09-10) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/package/manager/base.py b/platformio/package/manager/base.py index dcfe03f0..3664a72e 100644 --- a/platformio/package/manager/base.py +++ b/platformio/package/manager/base.py @@ -51,7 +51,7 @@ class BasePackageManager( # pylint: disable=too-many-public-methods def __init__(self, pkg_type, package_dir): self.pkg_type = pkg_type - self.package_dir = self.ensure_dir_exists(package_dir) + self.package_dir = package_dir self._MEMORY_CACHE = {} self._lockfile = None @@ -62,7 +62,9 @@ class BasePackageManager( # pylint: disable=too-many-public-methods def lock(self): if self._lockfile: return + self.ensure_dir_exists(os.path.dirname(self.package_dir)) self._lockfile = LockFile(self.package_dir) + self.ensure_dir_exists(self.package_dir) self._lockfile.acquire() def unlock(self): @@ -91,10 +93,7 @@ class BasePackageManager( # pylint: disable=too-many-public-methods @staticmethod def ensure_dir_exists(path): if not os.path.isdir(path): - try: - os.makedirs(path) - except: # pylint: disable=bare-except - pass + os.makedirs(path) assert os.path.isdir(path) return path @@ -193,6 +192,9 @@ class BasePackageManager( # pylint: disable=too-many-public-methods return metadata def get_installed(self): + if not os.path.isdir(self.package_dir): + return [] + cache_key = "get_installed" if self.memcache_get(cache_key): return self.memcache_get(cache_key)