Skip to content

Commit

Permalink
fix cleanup sequencing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Aug 24, 2024
1 parent 712bb5e commit d8b939f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions comfy_cli/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,21 @@ def FromDistro(
@staticmethod
def FromTarball(fpath: PathLike, name: PathLike = "python"):
fpath = Path(fpath)

with tarfile.open(fpath) as tar:
info = tar.next()
old_name = info.name.split("/")[0]
tar.extractall()

old_rpath = fpath.parent / old_name
rpath = fpath.parent / name
# clean the expanded destination

# clean the tar file expand target and the final target
shutil.rmtree(old_rpath, ignore_errors=True)
shutil.rmtree(rpath, ignore_errors=True)

with tarfile.open(fpath) as tar:
tar.extractall()

shutil.move(old_rpath, rpath)
return StandalonePython(rpath=rpath)

Expand Down

0 comments on commit d8b939f

Please sign in to comment.