mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
replica.create_task -> import_task_with_uuid
This commit is contained in:
parent
0308b7a4c7
commit
656f7e9ea0
3 changed files with 6 additions and 4 deletions
|
@ -77,7 +77,7 @@ fn import_task<W: WriteColor>(
|
||||||
.as_str()
|
.as_str()
|
||||||
.ok_or_else(|| anyhow!("uuid is not a string"))?;
|
.ok_or_else(|| anyhow!("uuid is not a string"))?;
|
||||||
let uuid = Uuid::parse_str(uuid)?;
|
let uuid = Uuid::parse_str(uuid)?;
|
||||||
replica.create_task(uuid)?;
|
replica.import_task_with_uuid(uuid)?;
|
||||||
|
|
||||||
let mut description = None;
|
let mut description = None;
|
||||||
for (k, v) in task_json.drain() {
|
for (k, v) in task_json.drain() {
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn import_task<W: WriteColor>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let uuid = uuid.ok_or_else(|| anyhow!("task has no uuid"))?;
|
let uuid = uuid.ok_or_else(|| anyhow!("task has no uuid"))?;
|
||||||
replica.create_task(uuid)?;
|
replica.import_task_with_uuid(uuid)?;
|
||||||
|
|
||||||
let mut description = None;
|
let mut description = None;
|
||||||
for attr in line.attrs.drain(..) {
|
for attr in line.attrs.drain(..) {
|
||||||
|
|
|
@ -105,7 +105,9 @@ impl Replica {
|
||||||
/// Create a new task.
|
/// Create a new task.
|
||||||
pub fn new_task(&mut self, status: Status, description: String) -> anyhow::Result<Task> {
|
pub fn new_task(&mut self, status: Status, description: String) -> anyhow::Result<Task> {
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
let mut task = self.create_task(uuid)?.into_mut(self);
|
self.add_undo_point(false)?;
|
||||||
|
let taskmap = self.taskdb.apply(SyncOp::Create { uuid })?;
|
||||||
|
let mut task = Task::new(uuid, taskmap).into_mut(self);
|
||||||
task.set_description(description)?;
|
task.set_description(description)?;
|
||||||
task.set_status(status)?;
|
task.set_status(status)?;
|
||||||
task.set_entry(Utc::now())?;
|
task.set_entry(Utc::now())?;
|
||||||
|
@ -116,7 +118,7 @@ impl Replica {
|
||||||
/// Create a new, empty task with the given UUID. This is useful for importing tasks, but
|
/// Create a new, empty task with the given UUID. This is useful for importing tasks, but
|
||||||
/// otherwise should be avoided in favor of `new_task`. If the task already exists, this
|
/// otherwise should be avoided in favor of `new_task`. If the task already exists, this
|
||||||
/// does nothing and returns the existing task.
|
/// does nothing and returns the existing task.
|
||||||
pub fn create_task(&mut self, uuid: Uuid) -> anyhow::Result<Task> {
|
pub fn import_task_with_uuid(&mut self, uuid: Uuid) -> anyhow::Result<Task> {
|
||||||
self.add_undo_point(false)?;
|
self.add_undo_point(false)?;
|
||||||
let taskmap = self.taskdb.apply(SyncOp::Create { uuid })?;
|
let taskmap = self.taskdb.apply(SyncOp::Create { uuid })?;
|
||||||
Ok(Task::new(uuid, taskmap))
|
Ok(Task::new(uuid, taskmap))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue