From 60fdf4c82c5f7e14b210709d5e8a4de82aee4041 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Sun, 1 Feb 2026 08:35:05 -0800 Subject: [PATCH] Fix issue on windows where source files were removed before transfer. --- web_server.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web_server.py b/web_server.py index 1247a1be..469149ef 100644 --- a/web_server.py +++ b/web_server.py @@ -8183,6 +8183,17 @@ def _safe_move_file(src, dst): src = Path(src) dst = Path(dst) + # Ensure parent directory exists + dst.parent.mkdir(parents=True, exist_ok=True) + + # On Windows, shutil.move fails with FileExistsError if destination exists. + # Remove it first to prevent the error chain. + if dst.exists(): + try: + dst.unlink() + except Exception: + pass # If we can't remove it, let shutil.move handle the error + try: # Try standard move first (works if same filesystem) shutil.move(str(src), str(dst))