Skip to content

Commit

Permalink
fix(get.py): Remove existing files before extracting
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Aug 26, 2024
1 parent 0539ebf commit 3f00177
Show file tree
Hide file tree
Showing 2 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
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 3f00177

Please sign in to comment.