Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
🐛 Fix samefile detect error when file not exist, fix #401
Browse files Browse the repository at this point in the history
  • Loading branch information
mnixry committed Dec 16, 2022
1 parent 09ebbd0 commit 246b3f3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nonebot_plugin_gocqhttp/process/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,18 @@ async def _find_duplicate_process(self):
exe = Path(process.exe()).absolute()
except psutil.Error:
continue

if Path(exe).is_file() and (
BINARY_PATH.absolute().samefile(exe)
or self.cwd.absolute().samefile(cwd)
):
if not (exe.is_file() and cwd.is_dir()):
continue
if BINARY_PATH.absolute().samefile(exe) and self.cwd.samefile(cwd):
process.terminate()
return pid
yield pid
return

async def start(self):
if self.worker_thread_running:
raise ProcessAlreadyStarted

if duplicate_pid := await self._find_duplicate_process():
async for duplicate_pid in self._find_duplicate_process():
logger.warning(f"Possible {duplicate_pid=} found, terminated.")

if not self.config.exists:
Expand Down

0 comments on commit 246b3f3

Please sign in to comment.