mirror of
https://git.meli.delivery/meli/meli
synced 2024-11-19 03:25:38 +00:00
ui/sqlite3: warn user if db hasn't been initialised
This commit is contained in:
parent
f3a7fa6350
commit
ad7c91bc29
@ -76,6 +76,14 @@ pub fn db_path() -> Result<PathBuf> {
|
||||
//}
|
||||
//
|
||||
pub fn open_db() -> Result<Connection> {
|
||||
let db_path = db_path()?;
|
||||
if !db_path.exists() {
|
||||
return Err(MeliError::new("Database hasn't been initialised. Run `reindex` command"));
|
||||
}
|
||||
Connection::open(&db_path).map_err(|e| MeliError::new(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn open_or_create_db() -> Result<Connection> {
|
||||
let db_path = db_path()?;
|
||||
let mut set_mode = false;
|
||||
if !db_path.exists() {
|
||||
@ -262,7 +270,7 @@ pub fn remove(env_hash: EnvelopeHash) -> Result<()> {
|
||||
}
|
||||
|
||||
pub fn index(context: &mut crate::state::Context) -> Result<()> {
|
||||
let conn = open_db()?;
|
||||
let conn = open_or_create_db()?;
|
||||
let work_context = context.work_controller().get_context();
|
||||
let mutexes = context
|
||||
.accounts
|
||||
|
Loading…
Reference in New Issue
Block a user