Spaces:
Running
Running
| import os, shutil, tempfile | |
| def safe_copy_temp(src_path: str, suffix: str) -> str: | |
| """Copy a file to a managed temp path so the caller can delete their tmp safely.""" | |
| out = tempfile.NamedTemporaryFile(delete=False, suffix=suffix) | |
| out.close() | |
| shutil.copyfile(src_path, out.name) | |
| return out.name | |
| def safe_unlink(path: str) -> None: | |
| try: os.unlink(path) | |
| except Exception: pass | |