Fix error in update_channel_buffer when there are no operations to store

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-08-23 11:30:43 -07:00
parent 199be8241c
commit 3268cce41a

View File

@ -215,7 +215,7 @@ impl Database {
user: UserId,
operations: &[proto::Operation],
) -> Result<Vec<ConnectionId>> {
self.transaction(|tx| async move {
self.transaction(move |tx| async move {
self.check_user_is_channel_member(channel_id, user, &*tx)
.await?;
@ -240,11 +240,15 @@ impl Database {
.await?
.ok_or_else(|| anyhow!("missing buffer snapshot"))?;
buffer_operation::Entity::insert_many(operations.iter().filter_map(|operation| {
operation_to_storage(operation, &buffer, serialization_version)
}))
.exec(&*tx)
.await?;
let operations = operations
.iter()
.filter_map(|op| operation_to_storage(op, &buffer, serialization_version))
.collect::<Vec<_>>();
if !operations.is_empty() {
buffer_operation::Entity::insert_many(operations)
.exec(&*tx)
.await?;
}
let mut connections = Vec::new();
let mut rows = channel_buffer_collaborator::Entity::find()