···119119 // WARN: we could improperly increment the id if the task is not written to disk/errors.
120120 // But who cares
121121 let id = self.next_id()?;
122122- let task_path = self.path.join("tasks").join(format!("tsk-{}.tsk", id.0));
122122+ // the task goes in the archive first
123123+ let task_path = self.path.join("archive").join(format!("tsk-{}.tsk", id.0));
123124 let mut file = util::flopen(task_path.clone(), FlockArg::LockExclusive)?;
124125 file.write_all(format!("{title}\n\n{body}").as_bytes())?;
125125- // create a hardlink to the archive dir
126126+ // create a hardlink to the task dir to mark it as "open"
126127 fs::hard_link(
127128 task_path,
128128- self.path.join("archive").join(format!("tsk-{}.tsk", id.0)),
129129+ self.path.join("tasks").join(format!("tsk-{}.tsk", id.0)),
129130 )?;
130131 Ok(Task {
131132 id,