refactor(browser-manager): hoist resolvedRoot out of screenshot filter chain

This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 22:56:46 -04:00
1 parent 4000854b69
commit 0706ad78bb
1 file changed
+1 -1
+1 -1
View File
@@ -60,12 +60,12 @@ export class BrowserManager {
log.warn(`[browser] Failed to fully clear session for ${socialAccountId}: ${error instanceof Error ? error.message : String(error)}`);
}
const resolvedRoot = resolve(this.screenshotDir);
await Promise.all(
screenshotPaths
.filter((entry): entry is string => typeof entry === "string" && entry.length > 0)
.filter((screenshotPath) => {
const resolvedPath = resolve(screenshotPath);
const resolvedRoot = resolve(this.screenshotDir);
return resolvedPath === resolvedRoot || resolvedPath.startsWith(`${resolvedRoot}${sep}`);
})
.map((screenshotPath) => rm(screenshotPath, { force: true }).catch(() => undefined)),