Commit a95880aa86

a95880aa86d5601398a1b4078d1b143d1cd13541

parent: 426b9c64cc

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-01-12 11:02 UTC

lib: Don't read the config in an async task.

Layout: unified · split

src/lib.rs +12 −8
@@ -95,18 +95,22 @@ impl WeechatPlugin for Matrix {
9595 config: config.clone(),
9696 };
9797
98 spawn_weechat(async move {
99 {
100 let config = config.borrow();
101 config.read().expect("Can't read config");
98 {
99 let config_borrow = config.borrow();
100 if config_borrow.read().is_err() {
101 return Err(weechat::Error(-1));
102102 }
103 }
103104
104 let mut servers = servers.borrow_mut();
105
106 if servers.is_empty() {
107 Matrix::create_default_server(&mut servers, &config)
105 {
106 let mut servers_borrow = servers.borrow_mut();
107 if servers_borrow.is_empty() {
108 Matrix::create_default_server(&mut servers_borrow, &config)
108109 }
110 }
109111
112 spawn_weechat(async move {
113 let mut servers = servers.borrow_mut();
110114 Matrix::autoconnect(&mut servers);
111115 });
112116