-
Notifications
You must be signed in to change notification settings - Fork 1
Description
pocketcasts_latest_downloader/file/output.py
Lines 21 to 28 in 1ef4d85
| 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)