mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix tests
This commit is contained in:
@@ -533,7 +533,7 @@ fn get_config_keys_str() -> String {
|
||||
let keys = &CONFIG_KEYS[..].join(" ");
|
||||
let sys_keys = &SYS_CONFIG_KEYS[..].join(" ");
|
||||
|
||||
format!("{} {}", keys, sys_keys)
|
||||
format!(" {} {} ", keys, sys_keys)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
||||
|
||||
@@ -964,7 +964,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
|
||||
/*for logging only*/
|
||||
let sql = SQLite::new();
|
||||
if sql.open(context, as_path(dest_pathNfilename), 0) {
|
||||
if 0 == dc_sqlite3_table_exists(context, &sql, "backup_blobs") {
|
||||
if !sql.table_exists("backup_blobs") {
|
||||
if !dc_sqlite3_execute(
|
||||
context,
|
||||
&sql,
|
||||
|
||||
@@ -107,19 +107,21 @@ impl SQLite {
|
||||
|
||||
pub fn table_exists(&self, name: impl AsRef<str>) -> bool {
|
||||
match &*self.connection.read().unwrap() {
|
||||
Some(conn) => {
|
||||
conn.pragma(None, "table_info", &format!("{}", name.as_ref()), |row| {
|
||||
// will only be executed if the info was found
|
||||
println!("row: {:?}", row.get::<_, String>(0)?);
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
Some(conn) => table_exists(conn, name),
|
||||
None => panic!("Querying closed SQLite database"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn table_exists(conn: &Connection, name: impl AsRef<str>) -> bool {
|
||||
conn.pragma(None, "table_info", &format!("{}", name.as_ref()), |row| {
|
||||
// will only be executed if the info was found
|
||||
println!("row: {:?}", row.get::<_, String>(0)?);
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
// Return 1 -> success
|
||||
// Return 0 -> failure
|
||||
fn dc_sqlite3_open(
|
||||
@@ -161,7 +163,7 @@ fn dc_sqlite3_open(
|
||||
}
|
||||
}
|
||||
|
||||
let conn_lock = sql.connection.write().unwrap();
|
||||
let conn_lock = sql.connection.read().unwrap();
|
||||
let conn = conn_lock.as_ref().expect("just opened");
|
||||
|
||||
conn.pragma_update(None, "secure_delete", &"on".to_string())
|
||||
@@ -173,7 +175,7 @@ fn dc_sqlite3_open(
|
||||
let mut exists_before_update = 0;
|
||||
let mut dbversion_before_update = 0;
|
||||
/* Init tables to dbversion=0 */
|
||||
if 0 == dc_sqlite3_table_exists(context, sql, "config") {
|
||||
if !table_exists(conn, "config") {
|
||||
info!(
|
||||
context,
|
||||
0,
|
||||
@@ -339,12 +341,12 @@ fn dc_sqlite3_open(
|
||||
"CREATE INDEX jobs_index1 ON jobs (desired_timestamp);",
|
||||
params![],
|
||||
);
|
||||
if 0 == dc_sqlite3_table_exists(context, sql, "config")
|
||||
|| 0 == dc_sqlite3_table_exists(context, sql, "contacts")
|
||||
|| 0 == dc_sqlite3_table_exists(context, sql, "chats")
|
||||
|| 0 == dc_sqlite3_table_exists(context, sql, "chats_contacts")
|
||||
|| 0 == dc_sqlite3_table_exists(context, sql, "msgs")
|
||||
|| 0 == dc_sqlite3_table_exists(context, sql, "jobs")
|
||||
if !table_exists(conn, "config")
|
||||
|| !table_exists(conn, "contacts")
|
||||
|| !table_exists(conn, "chats")
|
||||
|| !table_exists(conn, "chats_contacts")
|
||||
|| !table_exists(conn, "msgs")
|
||||
|| !table_exists(conn, "jobs")
|
||||
{
|
||||
error!(
|
||||
context,
|
||||
@@ -965,17 +967,6 @@ pub fn dc_sqlite3_get_config_int(
|
||||
.unwrap_or_else(|| def)
|
||||
}
|
||||
|
||||
pub fn dc_sqlite3_table_exists(
|
||||
_context: &Context,
|
||||
sql: &SQLite,
|
||||
name: impl AsRef<str>,
|
||||
) -> libc::c_int {
|
||||
match sql.table_exists(name) {
|
||||
true => 1,
|
||||
false => 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dc_sqlite3_set_config_int64(
|
||||
context: &Context,
|
||||
sql: &SQLite,
|
||||
|
||||
Reference in New Issue
Block a user