mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
chore: use a temporary path for db in example
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
*.db
|
||||
|
||||
# ignore vi temporaries
|
||||
*~
|
||||
|
||||
@@ -22,15 +22,18 @@ reqwest = "0.9.15"
|
||||
num-derive = "0.2.5"
|
||||
num-traits = "0.2.6"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.0.7"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"deltachat-ffi"
|
||||
]
|
||||
|
||||
|
||||
[[example]]
|
||||
name = "simple"
|
||||
|
||||
[[example]]
|
||||
name = "repl"
|
||||
path = "examples/repl/main.rs"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ extern crate deltachat;
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ptr::NonNull;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use deltachat::constants::Event;
|
||||
use deltachat::dc_chat::*;
|
||||
@@ -73,24 +74,24 @@ fn main() {
|
||||
dc_perform_smtp_idle(sendable_ctx.0.as_ptr());
|
||||
});
|
||||
|
||||
let dbfile = CString::new("../deltachat-core/build/hello2.db").unwrap();
|
||||
println!("opening dir");
|
||||
let dir = tempdir().unwrap();
|
||||
let dbfile = CString::new(dir.path().join("db.sqlite").to_str().unwrap()).unwrap();
|
||||
|
||||
println!("opening database {:?}", dbfile);
|
||||
dc_open(ctx, dbfile.as_ptr(), std::ptr::null());
|
||||
|
||||
if dc_is_configured(ctx) == 0 {
|
||||
println!("configuring");
|
||||
dc_set_config(
|
||||
ctx,
|
||||
CString::new("addr").unwrap().as_ptr(),
|
||||
CString::new("d@testrun.org").unwrap().as_ptr(),
|
||||
);
|
||||
dc_set_config(
|
||||
ctx,
|
||||
CString::new("mail_pw").unwrap().as_ptr(),
|
||||
CString::new("***").unwrap().as_ptr(),
|
||||
);
|
||||
dc_configure(ctx);
|
||||
}
|
||||
println!("configuring");
|
||||
dc_set_config(
|
||||
ctx,
|
||||
CString::new("addr").unwrap().as_ptr(),
|
||||
CString::new("d@testrun.org").unwrap().as_ptr(),
|
||||
);
|
||||
dc_set_config(
|
||||
ctx,
|
||||
CString::new("mail_pw").unwrap().as_ptr(),
|
||||
CString::new("***").unwrap().as_ptr(),
|
||||
);
|
||||
dc_configure(ctx);
|
||||
|
||||
std::thread::sleep_ms(4000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user