Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix: resolve comments

AbhinRustagi25cfd2777fa3
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index f04b7c337..5e26c4480 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -77,7 +77,13 @@ interface Window {
videoData: ArrayBuffer,
fileName: string,
exportFolder?: string,
- ) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>;
+ ) => Promise<{
+ success: boolean;
+ path?: string;
+ message?: string;
+ canceled?: boolean;
+ error?: string;
+ }>;
openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;
setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>;
setCurrentRecordingSession: (
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index 9a8e9cafe..cb8d217a3 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -842,8 +842,14 @@ export function registerIpcHandlers(
if (stats.isDirectory()) {
defaultDir = exportFolder;
}
- } catch {
- // Folder was moved or deleted since the last export; keep Downloads.
+ } catch (err) {
+ // Stat can fail because the folder was moved/deleted (expected) or
+ // because of a permission error (worth surfacing). Either way we
+ // fall back to Downloads, but log so debugging isn't blind.
+ console.warn(
+ `Could not access remembered export folder "${exportFolder}", falling back to Downloads:`,
+ err,
+ );
}
}
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index cf174fa28..46957a315 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -31,7 +31,12 @@ import {
import { computeFrameStepTime } from "@/lib/frameStep";
import type { ProjectMedia } from "@/lib/recordingSession";
import { matchesShortcut } from "@/lib/shortcuts";
-import { loadUserPreferences, parentDirectoryOf, saveUserPreferences } from "@/lib/userPreferences";
+import {
+ getExportFolder,
+ loadUserPreferences,
+ parentDirectoryOf,
+ saveUserPreferences,
+} from "@/lib/userPreferences";
import { BackgroundLoadError } from "@/lib/wallpaper";
import {
getAspectRatioValue,
@@ -1313,7 +1318,7 @@ export default function VideoEditor() {
const saveResult = await window.electronAPI.saveExportedVideo(
unsavedExport.arrayBuffer,
unsavedExport.fileName,
- loadUserPreferences().exportFolder ?? undefined,
+ getExportFolder(),
);
if (saveResult.canceled) {
toast.info("Export canceled");
@@ -1418,7 +1423,7 @@ export default function VideoEditor() {
const saveResult = await window.electronAPI.saveExportedVideo(
arrayBuffer,
fileName,
- loadUserPreferences().exportFolder ?? undefined,
+ getExportFolder(),
);
if (saveResult.canceled) {
@@ -1562,7 +1567,7 @@ export default function VideoEditor() {
const saveResult = await window.electronAPI.saveExportedVideo(
arrayBuffer,
fileName,
- loadUserPreferences().exportFolder ?? undefined,
+ getExportFolder(),
);
if (saveResult.canceled) {
diff --git a/src/lib/userPreferences.ts b/src/lib/userPreferences.ts
index 2c9db6f94..5b7bc86d9 100644
--- a/src/lib/userPreferences.ts
+++ b/src/lib/userPreferences.ts
@@ -112,6 +112,14 @@ export function parentDirectoryOf(filePath: string): string | null {
return filePath.slice(0, lastSep);
}
+/**
+ * Returns the remembered export folder as `string | undefined`, suitable for
+ * passing directly to IPC handlers that treat absence as "use the default".
+ */
+export function getExportFolder(): string | undefined {
+ return loadUserPreferences().exportFolder ?? undefined;
+}
+
/**
* Persist user preferences to localStorage.
* Only the explicitly provided fields are updated.