This commit is contained in:
Hocuri
2020-09-16 15:00:22 +02:00
parent f9cc3cbef0
commit 396ccebb5c
2 changed files with 17 additions and 12 deletions

View File

@@ -123,7 +123,7 @@ async fn cleanup_aborted_imex(context: &Context, what: ImexMode) {
.sql .sql
.open(context, context.get_dbfile(), false) .open(context, context.get_dbfile(), false)
.await .await
.ok(); .map_err(|e| warn!(context, "Re-opening db after imex failed: {}", e));
} }
} }
@@ -171,17 +171,23 @@ pub async fn has_backup_old(context: &Context, dir_name: impl AsRef<Path>) -> Re
let name = name.to_string_lossy(); let name = name.to_string_lossy();
if name.starts_with("delta-chat") && name.ends_with(".bak") { if name.starts_with("delta-chat") && name.ends_with(".bak") {
let sql = Sql::new(); let sql = Sql::new();
if sql.open(context, &path, true).await.is_ok() { match sql.open(context, &path, true).await {
let curr_backup_time = sql Ok(_) => {
.get_raw_config_int(context, "backup_time") let curr_backup_time = sql
.await .get_raw_config_int(context, "backup_time")
.unwrap_or_default(); .await
if curr_backup_time > newest_backup_time { .unwrap_or_default();
newest_backup_path = Some(path); if curr_backup_time > newest_backup_time {
newest_backup_time = curr_backup_time; newest_backup_path = Some(path);
newest_backup_time = curr_backup_time;
}
info!(context, "backup_time of {} is {}", name, curr_backup_time);
sql.close().await;
} }
info!(context, "backup_time of {} is {}", name, curr_backup_time); Err(e) => warn!(
sql.close().await; context,
"Found backup file {} which could not be opened: {}", name, e
),
} }
} }
} }

View File

@@ -78,7 +78,6 @@ impl Sql {
// drop closes the connection // drop closes the connection
} }
// return true on success, false on failure
pub async fn open<T: AsRef<Path>>( pub async fn open<T: AsRef<Path>>(
&self, &self,
context: &Context, context: &Context,