mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
fix(telegram): stage full proof artifacts safely
This commit is contained in:
@@ -1930,6 +1930,35 @@ function writeSession(pathname: string, session: SessionFile) {
|
||||
fs.chmodSync(pathname, 0o600);
|
||||
}
|
||||
|
||||
const FULL_ARTIFACT_JSON_NAMES = new Set([
|
||||
"probe.json",
|
||||
"status.json",
|
||||
"telegram-user-crabbox-proof-summary.json",
|
||||
"telegram-user-crabbox-session-summary.json",
|
||||
]);
|
||||
const FULL_ARTIFACT_FILE_EXTENSIONS = new Set([".gif", ".log", ".md", ".mp4", ".png"]);
|
||||
|
||||
export function stageFullSessionArtifacts(outputDir: string) {
|
||||
const publishDir = path.join(outputDir, "publish-full-artifacts");
|
||||
fs.rmSync(publishDir, { force: true, recursive: true });
|
||||
fs.mkdirSync(publishDir, { recursive: true });
|
||||
|
||||
for (const entry of fs.readdirSync(outputDir, { withFileTypes: true })) {
|
||||
if (!entry.isFile()) {
|
||||
continue;
|
||||
}
|
||||
const extension = path.extname(entry.name);
|
||||
const isPublishableArtifact =
|
||||
FULL_ARTIFACT_FILE_EXTENSIONS.has(extension) || FULL_ARTIFACT_JSON_NAMES.has(entry.name);
|
||||
if (!isPublishableArtifact) {
|
||||
continue;
|
||||
}
|
||||
fs.copyFileSync(path.join(outputDir, entry.name), path.join(publishDir, entry.name));
|
||||
}
|
||||
|
||||
return publishDir;
|
||||
}
|
||||
|
||||
function readSession(root: string, opts: Options, outputDir: string) {
|
||||
const pathname = sessionPath(root, opts, outputDir);
|
||||
if (!fs.existsSync(pathname)) {
|
||||
@@ -2462,7 +2491,7 @@ async function publishSessionArtifacts(root: string, opts: Options, outputDir: s
|
||||
);
|
||||
const publishGifPath = fs.existsSync(croppedMotionGifPath) ? croppedMotionGifPath : motionGifPath;
|
||||
const publishDir = opts.publishFullArtifacts
|
||||
? session.outputDir
|
||||
? stageFullSessionArtifacts(session.outputDir)
|
||||
: path.join(session.outputDir, "publish-gif-only");
|
||||
if (!opts.publishFullArtifacts) {
|
||||
if (!fs.existsSync(publishGifPath)) {
|
||||
|
||||
Reference in New Issue
Block a user