From f4fa8b71dd890fe1e34f2abb32e1211f84da4dcf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 25 Aug 2019 11:43:17 +0200 Subject: [PATCH] Fix: Provide header flag for timetracking entries Signed-off-by: Matthias Beyer --- lib/domain/libimagtimetrack/Cargo.toml | 1 + lib/domain/libimagtimetrack/src/lib.rs | 4 ++-- lib/domain/libimagtimetrack/src/store.rs | 6 +++++- lib/domain/libimagtimetrack/src/timetracking.rs | 10 ++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/domain/libimagtimetrack/Cargo.toml b/lib/domain/libimagtimetrack/Cargo.toml index a1bd07d5..f8560f35 100644 --- a/lib/domain/libimagtimetrack/Cargo.toml +++ b/lib/domain/libimagtimetrack/Cargo.toml @@ -32,3 +32,4 @@ libimagerror = { version = "0.10.0", path = "../../../lib/core/libimager libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } libimagentrydatetime = { version = "0.10.0", path = "../../../lib/entry/libimagentrydatetime" } libimagentrytag = { version = "0.10.0", path = "../../../lib/entry/libimagentrytag" } +libimagentryutil = { version = "0.10.0", path = "../../../lib/entry/libimagentryutil" } diff --git a/lib/domain/libimagtimetrack/src/lib.rs b/lib/domain/libimagtimetrack/src/lib.rs index 9f3d2770..12d724d2 100644 --- a/lib/domain/libimagtimetrack/src/lib.rs +++ b/lib/domain/libimagtimetrack/src/lib.rs @@ -47,8 +47,8 @@ extern crate lazy_static; extern crate is_match; #[macro_use] extern crate failure; -#[macro_use] -extern crate libimagstore; +#[macro_use] extern crate libimagstore; +#[macro_use] extern crate libimagentryutil; extern crate libimagentrydatetime; extern crate libimagentrytag; extern crate libimagerror; diff --git a/lib/domain/libimagtimetrack/src/store.rs b/lib/domain/libimagtimetrack/src/store.rs index bf25a4df..efa9e051 100644 --- a/lib/domain/libimagtimetrack/src/store.rs +++ b/lib/domain/libimagtimetrack/src/store.rs @@ -32,10 +32,11 @@ use failure::Error; use libimagstore::store::Store; use libimagstore::store::FileLockEntry; use libimagentrydatetime::datepath::compiler::DatePathCompiler; +use libimagentryutil::isa::Is; use crate::constants::*; use crate::iter::get::TimeTrackingsGetIterator; - +use crate::timetracking::IsTimeTracking; use crate::tag::TimeTrackingTag as TTT; pub trait TimeTrackStore<'a> { @@ -93,6 +94,9 @@ impl<'a> TimeTrackStore<'a> for Store { .map_err(Error::from) .map(|_| fle) }) + .and_then(|mut fle| { + fle.set_isflag::().map(|_| fle) + }) } fn create_timetracking(&'a self, start: &NDT, end: &NDT, ts: &TTT) -> Result> { diff --git a/lib/domain/libimagtimetrack/src/timetracking.rs b/lib/domain/libimagtimetrack/src/timetracking.rs index f47be7f7..52644a4a 100644 --- a/lib/domain/libimagtimetrack/src/timetracking.rs +++ b/lib/domain/libimagtimetrack/src/timetracking.rs @@ -28,6 +28,8 @@ use chrono::naive::NaiveDateTime; use libimagstore::store::Entry; use libimagerror::errors::ErrorMsg as EM; +use libimagentryutil::isa::Is; +use libimagentryutil::isa::IsKindHeaderPathProvider; use crate::tag::TimeTrackingTag as TTT; use crate::constants::*; @@ -40,8 +42,12 @@ use failure::Fallible as Result; use failure::ResultExt; use failure::Error; +provide_kindflag_path!(pub IsTimeTracking, "timetrack.is_timetracking"); + pub trait TimeTracking { + fn is_timetracking(&self) -> Result; + fn get_timetrack_tag(&self) -> Result; fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()>; @@ -62,6 +68,10 @@ pub trait TimeTracking { impl TimeTracking for Entry { + fn is_timetracking(&self) -> Result { + self.is::().map_err(From::from) + } + fn get_timetrack_tag(&self) -> Result { self.get_header() .read_string(DATE_TIME_TAG_HEADER_PATH)