fix: Wait 50ms before reloading config, to avoid reading an empty file

This commit is contained in:
elkowar 2021-08-23 10:12:31 +02:00
parent 17750289a5
commit bbcc8a3d29
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F

View file

@ -167,6 +167,11 @@ async fn run_filewatch<P: AsRef<Path>>(config_dir: P, evt_send: UnboundedSender<
}); });
let (daemon_resp_sender, mut daemon_resp_response) = daemon_response::create_pair(); let (daemon_resp_sender, mut daemon_resp_response) = daemon_response::create_pair();
// without this sleep, reading the config file sometimes gives an empty file.
// This is probably a result of editors not locking the file correctly,
// and eww being too fast, thus reading the file while it's empty.
// There should be some cleaner solution for this, but this will do for now.
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
evt_send.send(app::DaemonCommand::ReloadConfigAndCss(daemon_resp_sender))?; evt_send.send(app::DaemonCommand::ReloadConfigAndCss(daemon_resp_sender))?;
tokio::spawn(async move { tokio::spawn(async move {
match daemon_resp_response.recv().await { match daemon_resp_response.recv().await {