Skip to content

Commit 3f00177

Browse files
committed
fix(get.py): Remove existing files before extracting
1 parent 0539ebf commit 3f00177

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tools/esp32-arduino-libs
2+
tools/xtensa-esp-elf
23
tools/xtensa-esp32-elf
34
tools/xtensa-esp32s2-elf
45
tools/xtensa-esp32s3-elf

tools/get.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def unpack(filename, destination, force_extract, checksum): # noqa: C901
233233
else:
234234
print(" Forcing extraction")
235235

236+
if os.path.isdir(os.path.join(destination, rename_to)):
237+
print('Removing existing {0} ...'.format(rename_to))
238+
shutil.rmtree(os.path.join(destination, rename_to), ignore_errors=True)
239+
236240
if filename.endswith("tar.gz"):
237241
if not cfile:
238242
cfile = tarfile.open(filename, "r:gz")
@@ -250,8 +254,6 @@ def unpack(filename, destination, force_extract, checksum): # noqa: C901
250254

251255
if rename_to != dirname:
252256
print("Renaming {0} to {1} ...".format(dirname, rename_to))
253-
if os.path.isdir(rename_to):
254-
shutil.rmtree(rename_to)
255257
shutil.move(dirname, rename_to)
256258

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

0 commit comments

Comments
 (0)