Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ataka/player-cli/player_cli/exploit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,18 @@ def exploit_download(
print(f'{ERROR_STR}: unsafe archive: link detected')
raise typer.Exit(code=1)

try:
os.mkdir(path)
except FileExistsError:
if overwrite:
print(f'{WARN_STR}: directory "{path}" already exists (proceeding anyway)')
else:
print(f'{ERROR_STR}: directory "{path}" already exists (use --overwrite to proceed anyway)')
# Check if the directory already exists and ask the user if
# overwriting is fine if overwrite is not explicitly specified
if os.path.exists(path) and not overwrite:
confirm_str = f'{ERROR_STR}: directory "{path}" already exists, do you want to overwrite it?'

overwrite_answer = Confirm.ask(confirm_str)
if not overwrite_answer:
raise typer.Exit(code=1)

# Recursivly create directories, not raising FileExistsError on
# existing directories(overwrite-case)
os.makedirs(path, exist_ok=True)
tar.extractall(path)


Expand Down