Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: FILE_MODIFICATION_THRESHOLD for checking recently modified files

Richie McIlroy113695f21619
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index bcaa51dde..3082b7d60 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -5,6 +5,7 @@ use tokio::sync::Mutex;
use std::env;
use std::process::{Command, Child, Stdio};
use std::path::PathBuf;
+use std::time::SystemTime;
use tauri::State;
use std::path::Path;
use serde::Serialize;
@@ -39,6 +40,8 @@ struct RecordingOptions {
aws_bucket: String
}
+const FILE_MODIFICATION_THRESHOLD: u64 = 5;
+
#[tauri::command]
async fn start_dual_recording(
state: State<'_, Arc<Mutex<RecordingState>>>,
@@ -284,9 +287,19 @@ async fn start_upload_loop(chunks_dir: PathBuf, options: RecordingOptions, video
};
let path = entry.path();
if path.is_file() && path.extension().map_or(false, |e| e == "ts") {
+ // Skip files that have been recently modified
+ if let Ok(metadata) = std::fs::metadata(&path) {
+ if let Ok(modified) = metadata.modified() {
+ if SystemTime::now().duration_since(modified).unwrap_or_default().as_secs() < FILE_MODIFICATION_THRESHOLD {
+ println!("Skipping recently modified file: {}", path.display());
+ continue;
+ }
+ }
+ }
+
let filepath_str = path.to_str().unwrap_or_default().to_owned();
- //Log the file path, and the video type in one print, starting with "Uploading video from"
+ // Log the file path, and the video type in one print, starting with "Uploading video from"
println!("Uploading video for {}: {}", video_type, filepath_str);
match upload_video(