Commit 739b699

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-04-30 09:21:22
fix(update): remove the source directory after syncing
1 parent 9bfb7ea
Changed files (1)
src
others
src/others/version.py
@@ -119,6 +119,8 @@ async def update_bot(message: Message):
         return
     sync_dir(Path(root).joinpath("src"), "/app")
     await modify_progress(status, text="✅升级成功\n重启Bot,请稍后...", force_update=True)
+    if Path(root).is_dir():
+        shutil.rmtree(root)
     os._exit(0)  # restarting is managed by s6-overlay
 
 
@@ -160,7 +162,6 @@ def sync_dir(src: str | Path, dst: str | Path):
         if dst_file.is_file() and fname not in files and not fname.startswith(DOWNLOAD_DIR):
             dst_file.unlink()
     del_empty_dir(dst_root)
-    shutil.rmtree(src_root)
 
 
 def del_empty_dir(root: Path):