Remove project from host connection when unregistering it

Antonio Scandurra created

Change summary

crates/server/src/rpc/store.rs | 7 +++++++
1 file changed, 7 insertions(+)

Detailed changes

crates/server/src/rpc/store.rs 🔗

@@ -297,6 +297,11 @@ impl Store {
                     }
 
                     let project = e.remove();
+
+                    if let Some(host_connection) = self.connections.get_mut(&connection_id) {
+                        host_connection.projects.remove(&project_id);
+                    }
+
                     if let Some(share) = &project.share {
                         for guest_connection in share.guests.keys() {
                             if let Some(connection) = self.connections.get_mut(&guest_connection) {
@@ -305,6 +310,8 @@ impl Store {
                         }
                     }
 
+                    #[cfg(test)]
+                    self.check_invariants();
                     Ok(project)
                 } else {
                     Err(anyhow!("no such project"))?