mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-23 20:16:41 +02:00
fix: Switch to taskwarrior v3.X backend
This commit is contained in:
parent
4902ecdb34
commit
d178b986ad
4 changed files with 20 additions and 18 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1329,7 +1329,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "taskwarrior-tui"
|
||||
version = "0.25.4"
|
||||
version = "0.26.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"better-panic",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
||||
[](https://github.com/kdheepak/taskwarrior-tui/actions?query=workflow%3ACI)
|
||||
[](./LICENSE)
|
||||
|
|
28
src/app.rs
28
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<SystemTime> {
|
||||
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<SystemTime> {
|
||||
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<SystemTime>) -> Result<bool> {
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue