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

create text_json folder if doesnt exist

matthew-heartful30b1d33ce1ac
diff --git a/screenpipe-vision/src/utils.rs b/screenpipe-vision/src/utils.rs
index 72f419899..4b717fb50 100644
--- a/screenpipe-vision/src/utils.rs
+++ b/screenpipe-vision/src/utils.rs
@@ -5,7 +5,7 @@ use log::{debug, error};
use rusty_tesseract::{Args, DataOutput, Image}; // Added import for Args, Image, DataOutput
use serde_json;
use std::collections::HashMap;
-use std::fs::File;
+use std::fs::{self, File};
use std::hash::{DefaultHasher, Hash, Hasher};
use std::io::Write;
use std::sync::Arc;
@@ -166,6 +166,12 @@ pub async fn save_text_files(
let id = frame_number;
debug!("Saving text files for frame {}", frame_number);
+ // Ensure the text_json directory exists
+ if let Err(e) = fs::create_dir_all("text_json") {
+ error!("Failed to create text_json directory: {}", e);
+ return;
+ }
+
let new_text_lines: Vec<String> = new_text_json
.iter()
.map(|record| record.get("text").cloned().unwrap_or_default())
@@ -220,4 +226,4 @@ pub async fn save_text_files(
}
}
}
-}
+}
\ No newline at end of file