mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-11-11 08:23:42 +00:00
Preserve renderer state through mute and export transitions, gate hover previews on a composed frame, and align timeline bounds with authored zoom intervals. Improve settings, cursor and webcam controls, inline recording countdown, project recovery and safe library cleanup.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import path from "node:path";
|
|
import fs from "node:fs/promises";
|
|
import { getProjectBackupPaths } from "./atomicSave";
|
|
|
|
type Dependencies = {
|
|
list: () => Promise<{ entries: Array<{ path: string }> }>;
|
|
trash: (path: string) => Promise<void>;
|
|
thumbnailPath: (path: string) => string;
|
|
thumbnailPaths?: (path: string) => string[];
|
|
};
|
|
/** Only library project files may be trashed; referenced recordings are never touched. */
|
|
export async function trashLibraryProjects(paths: unknown, deps: Dependencies) {
|
|
if (
|
|
!Array.isArray(paths) ||
|
|
!paths.length ||
|
|
paths.length > 500 ||
|
|
paths.some((p) => typeof p !== "string")
|
|
)
|
|
throw new Error("Invalid project selection");
|
|
const allowed = new Set((await deps.list()).entries.map((e) => path.resolve(e.path)));
|
|
const selected = [...new Set((paths as string[]).map((p) => path.resolve(p)))];
|
|
if (selected.some((p) => !allowed.has(p))) throw new Error("Project is not in the library");
|
|
const deleted: string[] = [];
|
|
const errors: string[] = [];
|
|
for (const projectPath of selected) {
|
|
try {
|
|
await deps.trash(projectPath);
|
|
deleted.push(projectPath);
|
|
for (const sidecar of [
|
|
...(deps.thumbnailPaths?.(projectPath) ?? [deps.thumbnailPath(projectPath)]),
|
|
...getProjectBackupPaths(projectPath),
|
|
]) {
|
|
try {
|
|
await fs.access(sidecar);
|
|
await deps.trash(sidecar);
|
|
} catch (e) {
|
|
if ((e as NodeJS.ErrnoException).code !== "ENOENT")
|
|
errors.push(`Could not trash project sidecar: ${sidecar}`);
|
|
}
|
|
}
|
|
} catch {
|
|
errors.push(`Could not trash ${path.basename(projectPath)}`);
|
|
}
|
|
}
|
|
return { deleted, errors };
|
|
}
|