Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions astrbot/core/updator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess
import sys
import time
import zipfile
Expand Down Expand Up @@ -135,6 +136,11 @@ def _exec_reboot(executable: str, argv: list[str]) -> None:
quoted_args = [f'"{arg}"' if " " in arg else arg for arg in argv[1:]]
os.execl(executable, quoted_executable, *quoted_args)
return
elif os.name == "nt":
subprocess.Popen(
[executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE
)
Comment on lines +140 to +142

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expression [executable] + argv[1:] is redundant because argv is already constructed with executable as its first element (see _build_reboot_argv). You can pass argv directly to subprocess.Popen to simplify the code and avoid unnecessary list slicing and concatenation.

Suggested change
subprocess.Popen(
[executable] + argv[1:], creationflags=subprocess.CREATE_NEW_CONSOLE
)
subprocess.Popen(
argv, creationflags=subprocess.CREATE_NEW_CONSOLE
)

os._exit(0)
os.execv(executable, argv)

def _reboot(self, delay: int = 3) -> None:
Expand Down
Loading