Update buffer files when synchronizing buffers

It's possible that the host was disconnected when attempting to notify
guests of a file save, so we need to transmit this in order to correctly
update the file's mtime.

Next failing seed OPERATIONS=200 SEED=6894
This commit is contained in:
Nathan Sobo 2023-01-04 12:33:48 -07:00
parent 1dd085fc92
commit 789bbf15b7
5 changed files with 35 additions and 16 deletions

View file

@ -359,7 +359,7 @@ impl FormatTrigger {
impl Project {
pub fn init(client: &Arc<Client>) {
client.add_model_message_handler(Self::handle_add_collaborator);
client.add_model_message_handler(Self::handle_update_collaborator);
client.add_model_message_handler(Self::handle_update_project_collaborator);
client.add_model_message_handler(Self::handle_remove_collaborator);
client.add_model_message_handler(Self::handle_buffer_reloaded);
client.add_model_message_handler(Self::handle_buffer_saved);
@ -4617,7 +4617,7 @@ impl Project {
Ok(())
}
async fn handle_update_collaborator(
async fn handle_update_project_collaborator(
this: ModelHandle<Self>,
envelope: TypedEnvelope<proto::UpdateProjectCollaborator>,
_: Arc<Client>,
@ -5184,9 +5184,20 @@ impl Project {
let operations = buffer.serialize_ops(Some(remote_version), cx);
let client = this.client.clone();
let file = buffer.file().cloned();
cx.background()
.spawn(
async move {
if let Some(file) = file {
client
.send(proto::UpdateBufferFile {
project_id,
buffer_id: buffer_id as u64,
file: Some(file.to_proto()),
})
.log_err();
}
let operations = operations.await;
for chunk in split_operations(operations) {
client