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

Method try_open

src/sql.rs:191–209  ·  view source on GitHub ↗
(&self, context: &Context, dbfile: &Path, passphrase: String)

Source from the content-addressed store, hash-verified

189 }
190
191 async fn try_open(&self, context: &Context, dbfile: &Path, passphrase: String) -> Result<()> {
192 *self.pool.write().await = Some(Self::new_pool(dbfile, passphrase.to_string())?);
193
194 if let Err(e) = self.run_migrations(context).await {
195 error!(context, "Running migrations failed: {e:#}");
196 // Emiting an error event probably doesn't work
197 // because we are in the process of opening the context,
198 // so there is no event emitter yet.
199 // So, try to report the error in other ways:
200 eprintln!("Running migrations failed: {e:#}");
201 context.set_migration_error(&format!("Updating Delta Chat failed. Please send this message to the Delta Chat developers, either at delta@merlinux.eu or at https://support.delta.chat.\n\n{e:#}"));
202 // We can't simply close the db for two reasons:
203 // a. backup export would fail
204 // b. The UI would think that the account is unconfigured (because `is_configured()` fails)
205 // and remove the account when the user presses "Back"
206 }
207
208 Ok(())
209 }
210
211 /// Updates SQL schema to the latest version.
212 pub async fn run_migrations(&self, context: &Context) -> Result<()> {

Callers 1

openMethod · 0.80

Calls 2

run_migrationsMethod · 0.80
set_migration_errorMethod · 0.80

Tested by

no test coverage detected