mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 23:24:30 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -37,18 +37,28 @@ export function resolveSubagentRegistryPath(): string {
|
||||
export function loadSubagentRegistryFromDisk(): Map<string, SubagentRunRecord> {
|
||||
const pathname = resolveSubagentRegistryPath();
|
||||
const raw = loadJsonFile(pathname);
|
||||
if (!raw || typeof raw !== "object") return new Map();
|
||||
if (!raw || typeof raw !== "object") {
|
||||
return new Map();
|
||||
}
|
||||
const record = raw as Partial<PersistedSubagentRegistry>;
|
||||
if (record.version !== 1 && record.version !== 2) return new Map();
|
||||
if (record.version !== 1 && record.version !== 2) {
|
||||
return new Map();
|
||||
}
|
||||
const runsRaw = record.runs;
|
||||
if (!runsRaw || typeof runsRaw !== "object") return new Map();
|
||||
if (!runsRaw || typeof runsRaw !== "object") {
|
||||
return new Map();
|
||||
}
|
||||
const out = new Map<string, SubagentRunRecord>();
|
||||
const isLegacy = record.version === 1;
|
||||
let migrated = false;
|
||||
for (const [runId, entry] of Object.entries(runsRaw)) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (!entry || typeof entry !== "object") {
|
||||
continue;
|
||||
}
|
||||
const typed = entry as LegacySubagentRunRecord;
|
||||
if (!typed.runId || typeof typed.runId !== "string") continue;
|
||||
if (!typed.runId || typeof typed.runId !== "string") {
|
||||
continue;
|
||||
}
|
||||
const legacyCompletedAt =
|
||||
isLegacy && typeof typed.announceCompletedAt === "number"
|
||||
? typed.announceCompletedAt
|
||||
@@ -81,7 +91,9 @@ export function loadSubagentRegistryFromDisk(): Map<string, SubagentRunRecord> {
|
||||
cleanupCompletedAt,
|
||||
cleanupHandled,
|
||||
});
|
||||
if (isLegacy) migrated = true;
|
||||
if (isLegacy) {
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
if (migrated) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user