fix(repository): saturating_add for in-memory version bump
create_task used a plain += on the in-memory version returned to the caller while FileSystemStorage uses saturating_add when serialising the frontmatter. The two would disagree at u64::MAX, and in debug builds the + operator would panic on overflow. Match the storage behaviour.
This commit is contained in:
parent
f276233be5
commit
c134624839
|
|
@ -26,7 +26,10 @@ impl TaskRepository {
|
|||
// Task operations
|
||||
pub fn create_task(&mut self, list_id: Uuid, mut task: Task) -> Result<Task> {
|
||||
self.storage.write_task(list_id, &task)?;
|
||||
task.version += 1;
|
||||
// Mirror the saturating increment that FileSystemStorage applies to
|
||||
// the on-disk frontmatter so the in-memory Task matches what was
|
||||
// written and doesn't wrap at u64::MAX.
|
||||
task.version = task.version.saturating_add(1);
|
||||
Ok(task)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue