mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
feat: understandable error message when accounts.lock can't be locked (#6695)
Targets https://github.com/chatmail/core/issues/6636 Right now the error message is: > Error: Delta Chat is already running. To use Delta Chat, you must first close the existing Delta Chat process, or restart your device. > > (accounts.lock lock file is already locked) other suggestions welcome!
This commit is contained in:
@@ -30,7 +30,7 @@ async fn main() {
|
|||||||
// thread, and it is impossible to cancel that read. This can make shutdown of the runtime hang
|
// thread, and it is impossible to cancel that read. This can make shutdown of the runtime hang
|
||||||
// until the user presses enter."
|
// until the user presses enter."
|
||||||
if let Err(error) = &r {
|
if let Err(error) = &r {
|
||||||
log::error!("Fatal error: {error:#}.")
|
log::error!("Error: {error:#}.")
|
||||||
}
|
}
|
||||||
std::process::exit(if r.is_ok() { 0 } else { 1 });
|
std::process::exit(if r.is_ok() { 0 } else { 1 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::collections::BTreeMap;
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{ensure, Context as _, Result};
|
use anyhow::{bail, ensure, Context as _, Result};
|
||||||
use futures::stream::FuturesUnordered;
|
use futures::stream::FuturesUnordered;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -73,9 +73,7 @@ impl Accounts {
|
|||||||
let config_file = dir.join(CONFIG_NAME);
|
let config_file = dir.join(CONFIG_NAME);
|
||||||
ensure!(config_file.exists(), "{:?} does not exist", config_file);
|
ensure!(config_file.exists(), "{:?} does not exist", config_file);
|
||||||
|
|
||||||
let config = Config::from_file(config_file, writable)
|
let config = Config::from_file(config_file, writable).await?;
|
||||||
.await
|
|
||||||
.context("failed to load accounts config")?;
|
|
||||||
let events = Events::new();
|
let events = Events::new();
|
||||||
let stockstrings = StockStrings::new();
|
let stockstrings = StockStrings::new();
|
||||||
let push_subscriber = PushSubscriber::new();
|
let push_subscriber = PushSubscriber::new();
|
||||||
@@ -460,7 +458,9 @@ impl Config {
|
|||||||
rx.await?;
|
rx.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
locked_rx.await?;
|
if locked_rx.await.is_err() {
|
||||||
|
bail!("Delta Chat is already running. To use Delta Chat, you must first close the existing Delta Chat process, or restart your device. (accounts.lock file is already locked)");
|
||||||
|
};
|
||||||
Ok(Some(lock_task))
|
Ok(Some(lock_task))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user