Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: windows paths

Louis Beaumont29013a1f1a34
diff --git a/screenpipe-audio/src/core.rs b/screenpipe-audio/src/core.rs
index 83cc40891..2859e4987 100644
--- a/screenpipe-audio/src/core.rs
+++ b/screenpipe-audio/src/core.rs
@@ -96,6 +96,14 @@ fn get_device_and_config(
let audio_device = if audio_device.to_string() == "default" {
host.default_input_device()
} else {
+ // print input device for debugging windows
+ if cfg!(windows) {
+ debug!(
+ "input devices: {:?}",
+ host.input_devices()?.map(|x| x.name()).collect::<Vec<_>>()
+ );
+ }
+
host.input_devices()?.find(|x| {
x.name()
.map(|y| {
@@ -363,4 +371,4 @@ pub fn default_output_device() -> Result<AudioDevice> {
info!("Using default output device: {}", device.name()?);
return Ok(AudioDevice::new(device.name()?, DeviceType::Output));
}
-}
\ No newline at end of file
+}
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index c7da8da66..501f7b929 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -8,6 +8,7 @@ use screenpipe_audio::{
TranscriptionResult,
};
use std::collections::HashMap;
+use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
@@ -215,10 +216,11 @@ async fn record_audio(
let device_control_clone = device_control_clone.clone();
let new_file_name = Utc::now().format("%Y-%m-%d_%H-%M-%S").to_string();
- let file_path = format!(
- "{}/{}_{}.mp4",
- output_path_clone, audio_device_clone, new_file_name
- );
+ let file_path = PathBuf::from(&*output_path_clone)
+ .join(format!("{}_{}.mp4", audio_device_clone, new_file_name))
+ .to_str()
+ .expect("Failed to create valid path")
+ .to_string();
info!(
"Starting record_and_transcribe for device {} (iteration {})",
audio_device_clone, iteration
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 4aad941e7..d49cfe8bf 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -4,6 +4,7 @@ use log::{debug, error, info, warn};
use screenpipe_core::find_ffmpeg_path;
use screenpipe_vision::{continuous_capture, CaptureResult, ControlMessage};
use std::collections::VecDeque;
+use std::path::PathBuf;
use std::process::Stdio;
use std::sync::Arc;
use tokio::io::AsyncWriteExt;
@@ -185,7 +186,11 @@ async fn save_frames_as_video(
let time = Utc::now();
let formatted_time = time.format("%Y-%m-%d_%H-%M-%S").to_string();
// Start new FFmpeg process with a new output file
- let output_file = format!("{}/{}.mp4", output_path, formatted_time);
+ let output_file = PathBuf::from(output_path)
+ .join(format!("{}.mp4", formatted_time))
+ .to_str()
+ .expect("Failed to create valid path")
+ .to_string();
// Call the callback with the new video chunk file path
new_chunk_callback(&output_file);
diff --git a/screenpipe-vision/src/utils.rs b/screenpipe-vision/src/utils.rs
index 4b717fb50..a95721e08 100644
--- a/screenpipe-vision/src/utils.rs
+++ b/screenpipe-vision/src/utils.rs
@@ -8,6 +8,7 @@ use std::collections::HashMap;
use std::fs::{self, File};
use std::hash::{DefaultHasher, Hash, Hasher};
use std::io::Write;
+use std::path::PathBuf;
use std::sync::Arc;
use std::time::{Duration, Instant};
use xcap::Monitor;
@@ -181,8 +182,8 @@ pub async fn save_text_files(
.iter()
.map(|record| record.get("text").cloned().unwrap_or_default())
.collect();
-
- let new_text_file_path = format!("text_json/new_text_{}.txt", id);
+ let base_path = PathBuf::from("text_json");
+ let new_text_file_path = base_path.join(format!("new_text_{}.txt", id));
let mut new_text_file = match File::create(&new_text_file_path) {
Ok(file) => file,
Err(e) => {
@@ -194,7 +195,7 @@ pub async fn save_text_files(
writeln!(new_text_file, "{}", line).unwrap();
}
- let current_text_file_path = format!("text_json/current_text_{}.txt", id);
+ let current_text_file_path = base_path.join(format!("current_text_{}.txt", id));
let mut current_text_file = match File::create(&current_text_file_path) {
Ok(file) => file,
Err(e) => {
@@ -211,7 +212,7 @@ pub async fn save_text_files(
.iter()
.map(|record| record.get("text").cloned().unwrap_or_default())
.collect();
- let prev_text_file_path = format!("text_json/previous_text_{}.txt", id);
+ let prev_text_file_path = base_path.join(format!("previous_text_{}.txt", id));
let mut prev_text_file = match File::create(&prev_text_file_path) {
Ok(file) => file,
Err(e) => {
@@ -226,4 +227,4 @@ pub async fn save_text_files(
}
}
}
-}
\ No newline at end of file
+}