diff --git a/Cargo.lock b/Cargo.lock index 8981dc3..4310507 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1329,7 +1329,7 @@ dependencies = [ [[package]] name = "taskwarrior-tui" -version = "0.25.4" +version = "0.26.0" dependencies = [ "anyhow", "better-panic", diff --git a/Cargo.toml b/Cargo.toml index d4ef53b..f08e5d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "taskwarrior-tui" -version = "0.25.4" +version = "0.26.0" license = "MIT" description = "A Taskwarrior Terminal User Interface" repository = "https://github.com/kdheepak/taskwarrior-tui/" @@ -18,9 +18,7 @@ better-panic = "0.3.0" cassowary = "0.3.0" chrono = "0.4.26" clap = { version = "4.4.1", features = ["derive"] } -crossterm = { version = "0.27.0", features = [ - "event-stream", -] } +crossterm = { version = "0.27.0", features = ["event-stream"] } dirs = "5.0.1" futures = "0.3.28" itertools = "0.11.0" diff --git a/README.md b/README.md index c3c944f..1fcfa33 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # `taskwarrior-tui` > [!IMPORTANT] -> `taskwarrior-tui` is only tested with `taskwarrior` v2.x. [`taskwarrior` v3.x](https://github.com/GothenburgBitFactory/taskwarrior/releases/tag/v3.0.0) may not work as intended. +> [`taskwarrior` v3.x](https://github.com/GothenburgBitFactory/taskwarrior/releases/tag/v3.0.0) may break `taskwarrior-tui` features in unexpected ways. Please file a bug report if you encounter a bug. [![CI](https://github.com/kdheepak/taskwarrior-tui/workflows/CI/badge.svg)](https://github.com/kdheepak/taskwarrior-tui/actions?query=workflow%3ACI) [![](https://img.shields.io/github/license/kdheepak/taskwarrior-tui)](./LICENSE) diff --git a/src/app.rs b/src/app.rs index 271e4d4..05963a5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -64,7 +64,7 @@ const MAX_LINE: usize = 4096; lazy_static! { static ref START_TIME: Instant = Instant::now(); - static ref TASKWARRIOR_VERSION_SUPPORTED: Versioning = Versioning::new("2.6.0").unwrap(); + static ref TASKWARRIOR_VERSION_SUPPORTED: Versioning = Versioning::new("3.0.0").unwrap(); } #[derive(Debug)] @@ -1309,7 +1309,6 @@ impl TaskwarriorTui { } } - self.last_export = Some(std::time::SystemTime::now()); self.task_report_table.export_headers(None, &self.report)?; self.export_tasks()?; if self.config.uda_task_report_use_all_tasks_for_completion { @@ -1321,6 +1320,10 @@ impl TaskwarriorTui { self.task_details.clear(); self.dirty = false; self.save_history()?; + + // Some operations like export or summary change the taskwarrior database. + // The export time therefore gets set at the end, to avoid an infinite update loop. + self.last_export = Some(std::time::SystemTime::now()); } self.cursor_fix(); self.update_task_table_state(); @@ -1608,20 +1611,21 @@ impl TaskwarriorTui { } } - fn get_task_files_max_mtime(&self) -> Result { - let data_dir = shellexpand::tilde(&self.config.data_location).into_owned(); - ["backlog.data", "completed.data", "pending.data"] - .iter() - .map(|n| fs::metadata(Path::new(&data_dir).join(n)).map(|m| m.modified())) - .filter_map(Result::ok) - .filter_map(Result::ok) - .max() - .ok_or_else(|| anyhow!("Unable to get task files max time")) + fn get_task_database_mtime(&self) -> Result { + let data_dir = shellexpand::tilde(&self.config.data_location); + let database_path = Path::new(data_dir.as_ref()).join("taskchampion.sqlite3"); + + let metadata = fs::metadata(database_path).context("Fetching the metadate of the task database failed")?; + let mtime = metadata + .modified() + .context("Could not get mtime of task database, but fetching metadata succeeded")?; + + Ok(mtime) } pub fn tasks_changed_since(&mut self, prev: Option) -> Result { if let Some(prev) = prev { - let mtime = self.get_task_files_max_mtime()?; + let mtime = self.get_task_database_mtime()?; if mtime > prev { Ok(true) } else {