test(export): tighten media path regression coverage

This commit is contained in:
wiiiii123
2026-04-19 23:44:10 +07:00
parent 4f739a058e
commit cac33005e3
3 changed files with 18 additions and 14 deletions
+9
View File
@@ -64,4 +64,13 @@ describe("local media path policy", () => {
await expect(isAllowedLocalMediaPath(missingPath)).resolves.toBe(false);
});
it("allows approved media paths before the file exists", async () => {
const pendingExportPath = path.join(tempRoot, "Downloads", "pending-export.mp4");
const { isAllowedLocalMediaPath, rememberApprovedLocalReadPath } = await import("./manager");
await rememberApprovedLocalReadPath(pendingExportPath);
await expect(isAllowedLocalMediaPath(pendingExportPath)).resolves.toBe(true);
});
});
+1 -4
View File
@@ -64,10 +64,7 @@ export function isAllowedLocalReadPath(candidatePath: string) {
// saved outside the active recording session can still be reopened in the editor.
export async function isAllowedLocalMediaPath(candidatePath: string) {
const normalizedCandidatePath = normalizePath(candidatePath);
const realPath = await fs.realpath(normalizedCandidatePath).catch(() => normalizedCandidatePath);
return (
isAllowedLocalReadPath(normalizedCandidatePath) || isAllowedLocalReadPath(realPath)
);
return isAllowedLocalReadPath(normalizedCandidatePath);
}
export async function rememberApprovedLocalReadPath(filePath?: string | null) {
+8 -10
View File
@@ -16,27 +16,25 @@ import {
currentRecordingSession,
setCurrentRecordingSession,
} from "../state";
import { normalizeVideoSourcePath } from "../utils";
import {
getProjectsDir,
isAllowedLocalMediaPath,
isPathInsideDirectory,
isTrustedProjectPath,
listProjectLibraryEntries,
loadProjectFromPath,
persistRecordingsDirectorySetting,
replaceApprovedSessionLocalReadPaths,
rememberRecentProject,
saveProjectThumbnail,
} from "../project/manager";
import {
getTelemetryPathForVideo,
isAutoRecordingPath,
getRecordingsDir,
approveUserPath,
normalizeVideoSourcePath,
} from "../utils";
import {
getProjectsDir,
persistRecordingsDirectorySetting,
saveProjectThumbnail,
rememberRecentProject,
listProjectLibraryEntries,
loadProjectFromPath,
isTrustedProjectPath,
} from "../project/manager";
import { persistRecordingSessionManifest, resolveRecordingSession } from "../project/session";
function normalizeRecordingTimeOffsetMs(value: unknown): number {