import { mkdirSync, unlinkSync, writeFileSync } from "fs"; import path from "path"; import { MEDIA_UPLOAD_ROOT } from "@/lib/media-storage"; /** * Some sandboxed / read-only-mount environments allow writes but forbid `unlink`. * Filesystem round-trip tests that create AND delete managed media files self-skip * when deletion isn't permitted, so the suite stays green there while still running * fully on a normal filesystem (developer machine / CI). */ export const canManageUploads: boolean = (() => { try { const dir = path.join(MEDIA_UPLOAD_ROOT, "tests"); mkdirSync(dir, { recursive: true }); const probe = path.join(dir, `.cap-probe-${process.pid}-${Date.now()}`); writeFileSync(probe, "probe"); unlinkSync(probe); return true; } catch { return false; } })();