Guard delete_file with exists check

Only call os.remove if the target path exists to avoid raising an exception when attempting to delete a non-existent file. Makes delete_file safer/idempotent by checking exists(abs_path) before removal.

frdel committed Feb 23, 2026 at 16:39 UTC 7bd3ab6afb13971279ad05e0e5e8cc3a70e213bf
1 file changed +2 -1
python/helpers/files.py
+2 -1
@@ -425,7 +425,8 @@ def write_file(relative_path: str, content: str, encoding: str = "utf-8"):
425
426 def delete_file(relative_path: str):
427 abs_path = get_abs_path(relative_path)
428 - os.remove(abs_path)
428 + if exists(abs_path):
429 + os.remove(abs_path)
430
431 def write_file_bin(relative_path: str, content: bytes):
432 abs_path = get_abs_path(relative_path)