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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
release-app fix issue with cron pipes
Louis Beaumont5a0770368eff
diff --git a/Cargo.toml b/Cargo.tomlindex 618ce5fae..ff5acc9ba 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -14,7 +14,7 @@ resolver = "2"[workspace.package]-version = "0.2.21"+version = "0.2.22"authors = ["louis030195 <[email protected]>"]description = ""repository = "https://github.com/mediar-ai/screenpipe"diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lockindex e2f5e48aa..ab9ea9c55 100755--- a/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -4966,7 +4966,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "0.21.2"+version = "0.21.4"dependencies = ["anyhow","axum",diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex f7dcca5c5..798e0bee8 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.21.3"+version = "0.21.4"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rsindex b4431ded2..b2cc73a94 100644--- a/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -2,7 +2,6 @@ use crate::kill_all_sreenpipes;use crate::SidecarState;use anyhow::Error;use log::{error, info};-use std::env;use std::sync::Arc;use std::time::Duration;use tauri::menu::{MenuItem, MenuItemBuilder};diff --git a/screenpipe-core/src/pipes.rs b/screenpipe-core/src/pipes.rsindex ba01caa0c..173f87315 100644--- a/screenpipe-core/src/pipes.rs+++ b/screenpipe-core/src/pipes.rs@@ -824,16 +824,16 @@ mod pipes {// Get pipe directory for state persistencelet pipe_dir = screenpipe_dir.join("pipes").join(pipe);- // Get last execution time- let last_run = match get_last_cron_execution(&pipe_dir, path).await {- Ok(time) => time,- Err(e) => {- error!("failed to get last cron execution: {}", e);- None- }- };-loop {+ // Get last execution time at the start of each loop+ let last_run = match get_last_cron_execution(&pipe_dir, path).await {+ Ok(time) => time,+ Err(e) => {+ error!("failed to get last cron execution: {}", e);+ None+ }+ };+let now = chrono::Utc::now();let next = if let Some(last) = last_run {// Get next occurrence after the last execution@@ -845,42 +845,59 @@ mod pipes {let next = match next {Some(next) => next,- None => continue,+ None => {+ error!("no next execution time found for cron schedule");+ break;+ }};- let duration = (next - now)- .to_std()- .unwrap_or(tokio::time::Duration::from_secs(1));- tokio::time::sleep(duration).await;+ let duration = match (next - now).to_std() {+ Ok(duration) => duration,+ Err(e) => {+ error!("invalid duration: {}", e);+ tokio::time::Duration::from_secs(60) // fallback to 1 minute+ }+ };- debug!("executing cron job for pipe {} at path {}", pipe, path);+ debug!(+ "next cron execution for pipe {} at path {} in {} seconds",+ pipe,+ path,+ duration.as_secs()+ );- match client- .get(&format!("{}{}", base_url, path))- .headers(headers.clone())- .send()- .await- {- Ok(res) => {- if res.status().is_success() {- // Save successful execution time- if let Err(e) = save_cron_execution(&pipe_dir, path).await {- error!("failed to save cron execution time: {}", e);- }- } else {- error!("cron job failed with status: {}", res.status());- if let Ok(text) = res.text().await {- error!("error response: {}", text);+ // Wait for either the next execution time or shutdown signal+ tokio::select! {+ _ = tokio::time::sleep(duration) => {+ debug!("executing cron job for pipe {} at path {}", pipe, path);+ match client+ .get(&format!("{}{}", base_url, path))+ .headers(headers.clone())+ .send()+ .await+ {+ Ok(res) => {+ if res.status().is_success() {+ // Save successful execution time+ if let Err(e) = save_cron_execution(&pipe_dir, path).await {+ error!("failed to save cron execution time: {}", e);+ }+ debug!("cron job executed successfully");+ } else {+ error!("cron job failed with status: {}", res.status());+ if let Ok(text) = res.text().await {+ error!("error response: {}", text);+ }+ }}+ Err(e) => error!("failed to execute cron job: {}", e),}}- Err(e) => error!("failed to execute cron job: {}", e),- }-- if let Ok(()) = shutdown.changed().await {- if *shutdown.borrow() {- info!("cron job shutdown for pipe at path: {}", path);- break;+ Ok(()) = shutdown.changed() => {+ if *shutdown.borrow() {+ info!("shutting down cron job for pipe at path: {}", path);+ break;+ }}}}