diff --git a/lib/src/index_store.rs b/lib/src/index_store.rs index 97c4b50c5..e4311c0f2 100644 --- a/lib/src/index_store.rs +++ b/lib/src/index_store.rs @@ -75,8 +75,14 @@ impl IndexStore { } } - pub fn write_index(&self, index: MutableIndex) -> io::Result> { - index.save_in(self.dir.clone()) + pub fn write_index( + &self, + index: MutableIndex, + op_id: &OperationId, + ) -> io::Result> { + let index = index.save_in(self.dir.clone())?; + self.associate_file_with_operation(&index, op_id)?; + Ok(index) } fn load_index_at_operation( @@ -161,7 +167,7 @@ impl IndexStore { } /// Records a link from the given operation to the this index version. - pub fn associate_file_with_operation( + fn associate_file_with_operation( &self, index: &ReadonlyIndex, op_id: &OperationId, diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 7f2002ab9..afff05994 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -97,7 +97,6 @@ impl Transaction { ); let base_repo = mut_repo.base_repo().clone(); let (mut_index, view) = mut_repo.consume(); - let index = base_repo.index_store().write_index(mut_index).unwrap(); let view_id = base_repo.op_store().write_view(view.store_view()).unwrap(); self.op_metadata.end_time = self.end_time.unwrap_or_else(Timestamp::now); @@ -113,9 +112,9 @@ impl Transaction { .unwrap(); let operation = Operation::new(base_repo.op_store().clone(), new_op_id, store_operation); - base_repo + let index = base_repo .index_store() - .associate_file_with_operation(&index, operation.id()) + .write_index(mut_index, operation.id()) .unwrap(); UnpublishedOperation::new(base_repo.loader(), operation, view, index) }