mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 08:11:42 +00:00
fix: harden sandbox writes and centralize atomic file writes
This commit is contained in:
@@ -6,6 +6,7 @@ import readline from "node:readline";
|
||||
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveStateDir } from "../config/paths.js";
|
||||
import { writeFileWithinRoot } from "../infra/fs-safe.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import {
|
||||
materializeWindowsSpawnProgram,
|
||||
@@ -1410,11 +1411,17 @@ export class QmdMemoryManager implements MemorySearchManager {
|
||||
if (cutoff && entry.mtimeMs < cutoff) {
|
||||
continue;
|
||||
}
|
||||
const target = path.join(exportDir, `${path.basename(sessionFile, ".jsonl")}.md`);
|
||||
const targetName = `${path.basename(sessionFile, ".jsonl")}.md`;
|
||||
const target = path.join(exportDir, targetName);
|
||||
tracked.add(sessionFile);
|
||||
const state = this.exportedSessionState.get(sessionFile);
|
||||
if (!state || state.hash !== entry.hash || state.mtimeMs !== entry.mtimeMs) {
|
||||
await fs.writeFile(target, this.renderSessionMarkdown(entry), "utf-8");
|
||||
await writeFileWithinRoot({
|
||||
rootDir: exportDir,
|
||||
relativePath: targetName,
|
||||
data: this.renderSessionMarkdown(entry),
|
||||
encoding: "utf-8",
|
||||
});
|
||||
}
|
||||
this.exportedSessionState.set(sessionFile, {
|
||||
hash: entry.hash,
|
||||
|
||||
Reference in New Issue
Block a user