From a56f2393a48e3a3b8fd568bbb215eae972257d6b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:48:11 +0000 Subject: [PATCH] Address code review feedback - improve null checks Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- back/config/util.ts | 4 ++-- back/loaders/initData.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index 47b7b183..e4a7ce69 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -398,8 +398,8 @@ export function psTree(pid: number): Promise { } export function isPidRunning(pid: number): boolean { - // Validate PID is a positive integer - if (!pid || pid <= 0 || !Number.isInteger(pid)) { + // Validate PID: must be a positive integer + if (pid == null || pid <= 0 || !Number.isInteger(pid)) { return false; } diff --git a/back/loaders/initData.ts b/back/loaders/initData.ts index 8fbe3b08..c9d87c74 100644 --- a/back/loaders/initData.ts +++ b/back/loaders/initData.ts @@ -143,7 +143,9 @@ export default async () => { continue; } // 收集需要重置的任务 ID - idsToReset.push(cron.id!); + if (cron.id) { + idsToReset.push(cron.id); + } } // 批量更新所有需要重置的任务