Skip to content

Commit

Permalink
fix(get.py): Remove existing files before extracting (espressif#10247)
Browse files Browse the repository at this point in the history
* fix(get.py): Remove existing files before extracting

* change(tools): Push generated binaries to PR

* ci(pre-commit): Apply automatic fixes

* change(tools): Push generated binaries to PR

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 7633653 commit 5ecda3a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tools/esp32-arduino-libs
tools/xtensa-esp-elf
tools/xtensa-esp32-elf
tools/xtensa-esp32s2-elf
tools/xtensa-esp32s3-elf
Expand Down
Binary file modified tools/get.exe
Binary file not shown.
6 changes: 4 additions & 2 deletions tools/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def unpack(filename, destination, force_extract, checksum): # noqa: C901
else:
print(" Forcing extraction")

if os.path.isdir(os.path.join(destination, rename_to)):
print("Removing existing {0} ...".format(rename_to))
shutil.rmtree(os.path.join(destination, rename_to), ignore_errors=True)

if filename.endswith("tar.gz"):
if not cfile:
cfile = tarfile.open(filename, "r:gz")
Expand All @@ -250,8 +254,6 @@ def unpack(filename, destination, force_extract, checksum): # noqa: C901

if rename_to != dirname:
print("Renaming {0} to {1} ...".format(dirname, rename_to))
if os.path.isdir(rename_to):
shutil.rmtree(rename_to)
shutil.move(dirname, rename_to)

with open(os.path.join(destination, rename_to, ".package_checksum"), "w") as f:
Expand Down

0 comments on commit 5ecda3a

Please sign in to comment.