Do not further update 'modified' if it's explicitly set
This commit is contained in:
committed by
Dustin J. Mitchell
parent
b963af9b4b
commit
f94df28226
@@ -379,9 +379,18 @@ impl<'r> TaskMut<'r> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set a tasks's property by name.
|
/// Set a tasks's property by name.
|
||||||
|
///
|
||||||
|
/// This will not automatically update the `modified` timestamp or perform any other
|
||||||
|
/// "automatic" operations -- it simply sets the property. Howerver, if property is
|
||||||
|
/// "modified", then subsequent calls to other `set_..` methods will not update the
|
||||||
|
/// `modified` timestamp.
|
||||||
pub fn set_value<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
pub fn set_value<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
||||||
let property = property.into();
|
let property = property.into();
|
||||||
|
|
||||||
|
if &property == "modified" {
|
||||||
|
self.updated_modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref v) = value {
|
if let Some(ref v) = value {
|
||||||
trace!("task {}: set property {}={:?}", self.task.uuid, property, v);
|
trace!("task {}: set property {}={:?}", self.task.uuid, property, v);
|
||||||
} else {
|
} else {
|
||||||
@@ -531,7 +540,7 @@ impl<'r> TaskMut<'r> {
|
|||||||
|
|
||||||
fn set_string<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
fn set_string<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
||||||
let property = property.into();
|
let property = property.into();
|
||||||
// updated the modified timestamp unless we are setting it explicitly
|
// update the modified timestamp unless we are setting it explicitly
|
||||||
if &property != "modified" {
|
if &property != "modified" {
|
||||||
self.update_modified()?;
|
self.update_modified()?;
|
||||||
}
|
}
|
||||||
@@ -1195,4 +1204,17 @@ mod test {
|
|||||||
assert!(t2.has_tag(&stag(SyntheticTag::Unblocked)));
|
assert!(t2.has_tag(&stag(SyntheticTag::Unblocked)));
|
||||||
assert!(t2.has_tag(&stag(SyntheticTag::Blocking)));
|
assert!(t2.has_tag(&stag(SyntheticTag::Blocking)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_value_modiifed() {
|
||||||
|
with_mut_task(|mut task| {
|
||||||
|
// set the modified property to something in the past..
|
||||||
|
task.set_value("modified", Some("1671820000".into()))
|
||||||
|
.unwrap();
|
||||||
|
// update another property
|
||||||
|
task.set_description("fun times".into()).unwrap();
|
||||||
|
// verify the modified property was not updated
|
||||||
|
assert_eq!(task.get_value("modified").unwrap(), "1671820000")
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user