Skip to content

CRITICAL: Removing all files in the output directory could lead to disaster #7

@carafelix

Description

@carafelix

def clear_output_dir(directory: str, log: logging.Logger):
try:
for output_file in pathlib.Path(directory).glob("*"):
if output_file.is_file():
output_file.unlink()
except (FileNotFoundError, OSError) as e:
log.error(f"Failed to clear output dir {e}")
raise SystemExit

This piece of code could lead to extreme disruption of a system if someone would manually change the OUTPUT_DIR variable. Inadvertently losing files or corrupting the entire system if else.

I would recommend instead to keep it as an arg clear-output and limited only to .mp3 files, maybe? or since there is already a transfer.sh file that fulfill that porpoise, just keep it outside the main code?

I'll PR in just about it takes me to change some other stuff (copying and rm cache could be done sequentially in between each download since otherwise it takes the double amount of space to maintain a copy of cache, plus output dir could be specified as an arg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions