Add dashboard backup catalog and health tools
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { restoreSandboxArchive } from "@/app/lib/sandboxFiles"
|
||||
import { recordActivity } from "@/app/lib/activityLog"
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
@@ -19,6 +20,14 @@ export async function POST(
|
||||
const replace = rawReplace === "true" || rawReplace === "1"
|
||||
const payload = Buffer.from(await file.arrayBuffer())
|
||||
const restored = await restoreSandboxArchive(sandboxId, targetPath, file.name, payload, replace)
|
||||
await recordActivity({
|
||||
type: "backup.upload.restore",
|
||||
status: "success",
|
||||
sandboxId,
|
||||
sandboxName: restored.sandboxName,
|
||||
message: `Restored uploaded archive ${file.name} into ${restored.targetPath}.`,
|
||||
metadata: { targetPath: restored.targetPath, mode: restored.mode, bytes: restored.bytes },
|
||||
}).catch(() => undefined)
|
||||
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
@@ -27,6 +36,11 @@ export async function POST(
|
||||
})
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to restore sandbox backup"
|
||||
await recordActivity({
|
||||
type: "backup.upload.restore",
|
||||
status: "error",
|
||||
message,
|
||||
}).catch(() => undefined)
|
||||
return NextResponse.json({ ok: false, error: message }, { status: /required|path|large|unsafe|archive/.test(message) ? 400 : 500 })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user