Skip to content

Commit b200fe4

Browse files
authored
Allow deleting instant recordings after successful upload (#1192)
1 parent b99e6b3 commit b200fe4

File tree

6 files changed

+198
-333
lines changed

6 files changed

+198
-333
lines changed

apps/desktop/src-tauri/src/general_settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ pub struct GeneralSettingsStore {
120120
pub enable_new_uploader: bool,
121121
#[serde(default = "default_excluded_windows")]
122122
pub excluded_windows: Vec<WindowExclusion>,
123+
#[serde(default)]
124+
pub delete_instant_recordings_after_upload: bool,
123125
}
124126

125127
fn default_enable_native_camera_preview() -> bool {
@@ -184,6 +186,7 @@ impl Default for GeneralSettingsStore {
184186
post_deletion_behaviour: PostDeletionBehaviour::DoNothing,
185187
enable_new_uploader: default_enable_new_uploader(),
186188
excluded_windows: default_excluded_windows(),
189+
delete_instant_recordings_after_upload: false,
187190
}
188191
}
189192
}

apps/desktop/src-tauri/src/recording.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ async fn handle_recording_finish(
949949
.map_err(|err|
950950
error!("Error compressing thumbnail for instant mode progressive upload: {err}")
951951
) {
952-
crate::upload::singlepart_uploader(
952+
let res = crate::upload::singlepart_uploader(
953953
app.clone(),
954954
crate::api::PresignedS3PutRequest {
955955
video_id: video_upload_info.id.clone(),
@@ -959,13 +959,19 @@ async fn handle_recording_finish(
959959
},
960960
bytes.len() as u64,
961961
stream::once(async move { Ok::<_, std::io::Error>(bytes::Bytes::from(bytes)) }),
962-
963962
)
964-
.await
965-
.map_err(|err| {
966-
error!("Error updating thumbnail for instant mode progressive upload: {err}")
967-
})
968-
.ok();
963+
.await;
964+
if let Err(err) = res {
965+
error!("Error updating thumbnail for instant mode progressive upload: {err}");
966+
return;
967+
}
968+
969+
if GeneralSettingsStore::get(&app).ok().flatten().unwrap_or_default().delete_instant_recordings_after_upload {
970+
if let Err(err) = tokio::fs::remove_dir_all(&recording_dir).await {
971+
error!("Failed to remove recording files after upload: {err:?}");
972+
return;
973+
}
974+
}
969975
}
970976
} else if let Ok(meta) = build_video_meta(&output_path)
971977
.map_err(|err| error!("Error getting video metadata: {}", err))

apps/desktop/src/routes/(window-chrome)/settings/Setting.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Toggle } from "~/components/Toggle";
22

3-
export function Setting(props: {
3+
export function SettingItem(props: {
44
pro?: boolean;
55
label: string;
66
description?: string;
@@ -21,20 +21,20 @@ export function Setting(props: {
2121
);
2222
}
2323

24-
export function ToggleSetting(props: {
24+
export function ToggleSettingItem(props: {
2525
pro?: boolean;
2626
label: string;
2727
description?: string;
2828
value: boolean;
2929
onChange(v: boolean): void;
3030
}) {
3131
return (
32-
<Setting {...props}>
32+
<SettingItem {...props}>
3333
<Toggle
3434
size="sm"
3535
checked={props.value}
3636
onChange={(v) => props.onChange(v)}
3737
/>
38-
</Setting>
38+
</SettingItem>
3939
);
4040
}

apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createStore } from "solid-js/store";
33

44
import { generalSettingsStore } from "~/store";
55
import type { GeneralSettingsStore } from "~/utils/tauri";
6-
import { ToggleSetting } from "./Setting";
6+
import { ToggleSettingItem } from "./Setting";
77

88
export default function ExperimentalSettings() {
99
const [store] = createResource(() => generalSettingsStore.get());
@@ -55,23 +55,23 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
5555
<div class="space-y-3">
5656
<h3 class="text-sm text-gray-12 w-fit">Recording Features</h3>
5757
<div class="px-3 rounded-xl border divide-y divide-gray-3 border-gray-3 bg-gray-2">
58-
<ToggleSetting
58+
<ToggleSettingItem
5959
label="Custom cursor capture in Studio Mode"
6060
description="Studio Mode recordings will capture cursor state separately for customisation (size, smoothing) in the editor. Currently experimental as cursor events may not be captured accurately."
6161
value={!!settings.custom_cursor_capture2}
6262
onChange={(value) =>
6363
handleChange("custom_cursor_capture2", value)
6464
}
6565
/>
66-
<ToggleSetting
66+
<ToggleSettingItem
6767
label="Native camera preview"
6868
description="Show the camera preview using a native GPU surface instead of rendering it within the webview. This is not functional on certain Windows systems so your mileage may vary."
6969
value={!!settings.enableNativeCameraPreview}
7070
onChange={(value) =>
7171
handleChange("enableNativeCameraPreview", value)
7272
}
7373
/>
74-
<ToggleSetting
74+
<ToggleSettingItem
7575
label="Auto zoom on clicks"
7676
description="Automatically generate zoom segments around mouse clicks during Studio Mode recordings. This helps highlight important interactions in your recordings."
7777
value={!!settings.autoZoomOnClicks}
@@ -84,7 +84,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
8484
);
8585
}}
8686
/>
87-
<ToggleSetting
87+
<ToggleSettingItem
8888
label="New recording flow"
8989
description="New and improved flow for starting a recording! You may need to restart the app for this to take effect."
9090
value={!!settings.enableNewRecordingFlow}
@@ -97,7 +97,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
9797
);
9898
}}
9999
/>
100-
<ToggleSetting
100+
<ToggleSettingItem
101101
label="New uploader"
102102
description="Improved uploader for faster and more reliable uploads!"
103103
value={!!settings.enableNewUploader}

0 commit comments

Comments
 (0)