MCPcopy Create free account
hub / github.com/chatmail/core / open

Method open

src/sql.rs:250–272  ·  view source on GitHub ↗

Opens the provided database and runs any necessary migrations. If a database is already open, this will return an error.

(&self, context: &Context, passphrase: String)

Source from the content-addressed store, hash-verified

248 /// Opens the provided database and runs any necessary migrations.
249 /// If a database is already open, this will return an error.
250 pub async fn open(&self, context: &Context, passphrase: String) -> Result<()> {
251 if self.is_open().await {
252 error!(
253 context,
254 "Cannot open, database \"{:?}\" already opened.", self.dbfile,
255 );
256 bail!("SQL database is already opened.");
257 }
258
259 let passphrase_nonempty = !passphrase.is_empty();
260 self.try_open(context, &self.dbfile, passphrase).await?;
261 info!(context, "Opened database {:?}.", self.dbfile);
262 *self.is_encrypted.write().await = Some(passphrase_nonempty);
263
264 // setup debug logging if there is an entry containing its id
265 if let Some(xdc_id) = self
266 .get_raw_config_u32(Config::DebugLogging.as_ref())
267 .await?
268 {
269 set_debug_logging_xdc(context, Some(MsgId::new(xdc_id))).await?;
270 }
271 Ok(())
272 }
273
274 /// Changes the passphrase of encrypted database.
275 ///

Callers 14

startFunction · 0.45
dc_context_newFunction · 0.45
dc_context_openFunction · 0.45
save_fileMethod · 0.45
test_db_reopenFunction · 0.45
test_check_passphraseFunction · 0.45
mainFunction · 0.45

Calls 6

set_debug_logging_xdcFunction · 0.85
try_openMethod · 0.80
get_raw_config_u32Method · 0.80
is_openMethod · 0.45
is_emptyMethod · 0.45
as_refMethod · 0.45