Skip to content

Commit

Permalink
Fixed a "PermissionError" on Windows when running "clean" or "cleanal…
Browse files Browse the repository at this point in the history
…l" targets // Resolve #4331
  • Loading branch information
ivankravets committed Jun 27, 2022
1 parent 3c17b31 commit 99b5204
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ PlatformIO Core 6
* Fixed an issue when the `build_unflags <https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-unflags>`__ option was not applied to the ``ASPPFLAGS`` scope
* Fixed an issue on Windows OS when flags were wrapped to the temporary file while generating the `Compilation database "compile_commands.json" <https://docs.platformio.org/en/latest/integration/compile_commands.html>`__
* Fixed an issue with the `LDF <https://docs.platformio.org/en/latest/librarymanager/ldf.html>`__ when recursively scanning dependencies in the ``chain`` mode
* Fixed a "PermissionError" on Windows when running "clean" or "cleanall" targets (`issue #4331 <https://github.com/platformio/platformio-core/issues/4331>`_)

6.0.2 (2022-06-01)
~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 3 additions & 10 deletions platformio/builder/tools/piotarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,19 @@ def _relpath(path):

def _clean_dir(path):
clean_rel_path = _relpath(path)
for root, _, files in os.walk(path):
for f in files:
dst = os.path.join(root, f)
os.remove(dst)
print(
"Removed %s"
% (dst if not clean_rel_path.startswith(".") else _relpath(dst))
)
print(f"Removing `{clean_rel_path}` folder...", end="")
fs.rmtree(path)
print(" done!")

build_dir = env.subst("$BUILD_DIR")
libdeps_dir = env.subst("$PROJECT_LIBDEPS_DIR")
if os.path.isdir(build_dir):
_clean_dir(build_dir)
fs.rmtree(build_dir)
else:
print("Build environment is clean")

if clean_all and os.path.isdir(libdeps_dir):
_clean_dir(libdeps_dir)
fs.rmtree(libdeps_dir)

print("Done cleaning")

Expand Down

0 comments on commit 99b5204

Please sign in to comment.