···119 // WARN: we could improperly increment the id if the task is not written to disk/errors.
120 // But who cares
121 let id = self.next_id()?;
122- let task_path = self.path.join("tasks").join(format!("tsk-{}.tsk", id.0));
0123 let mut file = util::flopen(task_path.clone(), FlockArg::LockExclusive)?;
124 file.write_all(format!("{title}\n\n{body}").as_bytes())?;
125- // create a hardlink to the archive dir
126 fs::hard_link(
127 task_path,
128- self.path.join("archive").join(format!("tsk-{}.tsk", id.0)),
129 )?;
130 Ok(Task {
131 id,
···119 // WARN: we could improperly increment the id if the task is not written to disk/errors.
120 // But who cares
121 let id = self.next_id()?;
122+ // the task goes in the archive first
123+ let task_path = self.path.join("archive").join(format!("tsk-{}.tsk", id.0));
124 let mut file = util::flopen(task_path.clone(), FlockArg::LockExclusive)?;
125 file.write_all(format!("{title}\n\n{body}").as_bytes())?;
126+ // create a hardlink to the task dir to mark it as "open"
127 fs::hard_link(
128 task_path,
129+ self.path.join("tasks").join(format!("tsk-{}.tsk", id.0)),
130 )?;
131 Ok(Task {
132 id,