From bfaae20e815e047e70c7e9af42276efb7324b5af Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 7 Jul 2023 20:10:08 +0100 Subject: [PATCH] Prevent overwriting files when using create-device --- pywidevine/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pywidevine/main.py b/pywidevine/main.py index d0a9427..a0c4117 100644 --- a/pywidevine/main.py +++ b/pywidevine/main.py @@ -238,6 +238,10 @@ def create_device( out_dir = output or Path.cwd() out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd" + if out_path.exists(): + log.error(f"A file already exists at the path '{out_path}', cannot overwrite.") + return + out_path.parent.mkdir(parents=True, exist_ok=True) out_path.write_bytes(wvd_bin)