mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-03 14:10:32 +00:00
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.
This commit is contained in:
parent
420f70d7de
commit
7bd3ab6afb
1 changed files with 2 additions and 1 deletions
|
|
@ -425,7 +425,8 @@ def write_file(relative_path: str, content: str, encoding: str = "utf-8"):
|
|||
|
||||
def delete_file(relative_path: str):
|
||||
abs_path = get_abs_path(relative_path)
|
||||
os.remove(abs_path)
|
||||
if exists(abs_path):
|
||||
os.remove(abs_path)
|
||||
|
||||
def write_file_bin(relative_path: str, content: bytes):
|
||||
abs_path = get_abs_path(relative_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue