mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 23:05:49 +00:00
fix: clean up ipc edge cases
This commit is contained in:
@@ -97,6 +97,8 @@ export async function startInteractionCapture() {
|
||||
return;
|
||||
}
|
||||
|
||||
stopInteractionCapture();
|
||||
|
||||
try {
|
||||
const hook = loadUiohookModule();
|
||||
console.log(
|
||||
|
||||
@@ -298,8 +298,17 @@ export async function listProjectLibraryEntries() {
|
||||
|
||||
export async function loadProjectFromPath(projectPath: string) {
|
||||
const normalizedPath = normalizePath(projectPath);
|
||||
const content = await fs.readFile(normalizedPath, "utf-8");
|
||||
const project = JSON.parse(content);
|
||||
let project: unknown;
|
||||
try {
|
||||
const content = await fs.readFile(normalizedPath, "utf-8");
|
||||
project = JSON.parse(content);
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
canceled: false,
|
||||
message: `Failed to read project file: ${error instanceof Error ? error.message : String(error)}`,
|
||||
};
|
||||
}
|
||||
const mediaSources = await resolveProjectMediaSources(project);
|
||||
|
||||
if (!mediaSources.success) {
|
||||
|
||||
@@ -70,11 +70,14 @@ export async function resolveRecordingSessionManifest(
|
||||
}
|
||||
|
||||
const webcamPath = path.join(path.dirname(normalizedVideoPath), webcamFileName);
|
||||
await fs.access(webcamPath, fsConstants.F_OK);
|
||||
const webcamExists = await fs
|
||||
.access(webcamPath, fsConstants.F_OK)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
return {
|
||||
videoPath: normalizedVideoPath,
|
||||
webcamPath,
|
||||
webcamPath: webcamExists ? webcamPath : null,
|
||||
timeOffsetMs: normalizeRecordingTimeOffsetMs(parsed.timeOffsetMs),
|
||||
};
|
||||
} catch {
|
||||
|
||||
@@ -355,7 +355,8 @@ export function registerProjectHandlers() {
|
||||
return { success: false, error: 'Only auto-generated recordings can be deleted' };
|
||||
}
|
||||
const resolvedPath = await fs.realpath(filePath).catch(() => path.resolve(filePath));
|
||||
const recordingsDir = await getRecordingsDir();
|
||||
const recordingsDirRaw = await getRecordingsDir();
|
||||
const recordingsDir = await fs.realpath(recordingsDirRaw).catch(() => path.resolve(recordingsDirRaw));
|
||||
if (!isPathInsideDirectory(resolvedPath, recordingsDir) || !isAutoRecordingPath(resolvedPath)) {
|
||||
return { success: false, error: 'Only auto-generated recordings can be deleted' };
|
||||
}
|
||||
@@ -363,7 +364,10 @@ export function registerProjectHandlers() {
|
||||
// Also delete the cursor telemetry sidecar if it exists
|
||||
const telemetryPath = getTelemetryPathForVideo(resolvedPath);
|
||||
await fs.unlink(telemetryPath).catch(() => {});
|
||||
if (currentVideoPath === resolvedPath) {
|
||||
const currentResolved = currentVideoPath
|
||||
? await fs.realpath(currentVideoPath).catch(() => currentVideoPath)
|
||||
: null;
|
||||
if (currentResolved === resolvedPath) {
|
||||
setCurrentVideoPath(null);
|
||||
setCurrentRecordingSession(null);
|
||||
}
|
||||
|
||||
@@ -994,6 +994,11 @@ export function registerRecordingHandlers(
|
||||
return await finalizeStoredVideo(finalVideoPath)
|
||||
} catch (error) {
|
||||
console.error('Failed to stop FFmpeg recording:', error)
|
||||
try {
|
||||
ffmpegCaptureProcess?.kill()
|
||||
} catch {
|
||||
// ignore cleanup failures
|
||||
}
|
||||
setFfmpegCaptureProcess(null)
|
||||
setFfmpegCaptureTargetPath(null)
|
||||
setFfmpegScreenRecordingActive(false)
|
||||
|
||||
@@ -432,7 +432,14 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}
|
||||
<div class="border-wrap"></div>
|
||||
</body></html>`
|
||||
|
||||
await highlightWin.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`)
|
||||
try {
|
||||
await highlightWin.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`)
|
||||
} catch (loadError) {
|
||||
if (!highlightWin.isDestroyed()) {
|
||||
highlightWin.close()
|
||||
}
|
||||
throw loadError
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (!highlightWin.isDestroyed()) highlightWin.close()
|
||||
|
||||
Reference in New Issue
Block a user