mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
Allow to provide backup file which will be imported
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use async_std::task::block_on;
|
use async_std::{path::PathBuf, task::block_on};
|
||||||
use criterion::{
|
use criterion::{
|
||||||
async_executor::AsyncStdExecutor, black_box, criterion_group, criterion_main, BatchSize,
|
async_executor::AsyncStdExecutor, black_box, criterion_group, criterion_main, BatchSize,
|
||||||
Criterion,
|
Criterion,
|
||||||
};
|
};
|
||||||
use deltachat::{config::Config, context::Context, dc_receive_imf::dc_receive_imf};
|
use deltachat::{
|
||||||
|
config::Config,
|
||||||
|
context::Context,
|
||||||
|
dc_receive_imf::dc_receive_imf,
|
||||||
|
imex::{imex, ImexMode},
|
||||||
|
};
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
async fn recv_emails(context: Context, emails: &[&[u8]]) -> Context {
|
async fn recv_emails(context: Context, emails: &[&[u8]]) -> Context {
|
||||||
@@ -94,6 +99,18 @@ async fn create_context() -> Context {
|
|||||||
let context = Context::new("FakeOS".into(), dbfile.into(), id)
|
let context = Context::new("FakeOS".into(), dbfile.into(), id)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let backup: PathBuf = std::env::current_dir()
|
||||||
|
.unwrap()
|
||||||
|
.join("delta-chat-backup.tar")
|
||||||
|
.into();
|
||||||
|
if backup.exists().await {
|
||||||
|
println!("Importing backup");
|
||||||
|
imex(&context, ImexMode::ImportBackup, &backup)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let addr = "alice@example.com";
|
let addr = "alice@example.com";
|
||||||
context.set_config(Config::Addr, Some(addr)).await.unwrap();
|
context.set_config(Config::Addr, Some(addr)).await.unwrap();
|
||||||
context
|
context
|
||||||
|
|||||||
Reference in New Issue
Block a user