mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
address @dignifiedquire comments
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
cargo build -p deltachat_ffi
|
export DCC_RS_TARGET=release
|
||||||
|
|
||||||
|
cargo build -p deltachat_ffi --${DCC_RS_TARGET}
|
||||||
rm -rf build/ src/deltachat/*.so
|
rm -rf build/ src/deltachat/*.so
|
||||||
DCC_RS_DEV=`pwd`/.. pip install -e .
|
DCC_RS_DEV=`pwd`/.. pip install -e .
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class Account(object):
|
|||||||
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, ffi.NULL),
|
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, ffi.NULL),
|
||||||
_destroy_dc_context,
|
_destroy_dc_context,
|
||||||
)
|
)
|
||||||
|
self._threads = IOThreads(self._dc_context)
|
||||||
if hasattr(db_path, "encode"):
|
if hasattr(db_path, "encode"):
|
||||||
db_path = db_path.encode("utf8")
|
db_path = db_path.encode("utf8")
|
||||||
if not lib.dc_open(self._dc_context, db_path, ffi.NULL):
|
if not lib.dc_open(self._dc_context, db_path, ffi.NULL):
|
||||||
@@ -43,7 +44,6 @@ class Account(object):
|
|||||||
if eventlogging:
|
if eventlogging:
|
||||||
self._evlogger = EventLogger(self._dc_context, logid)
|
self._evlogger = EventLogger(self._dc_context, logid)
|
||||||
deltachat.set_context_callback(self._dc_context, self._process_event)
|
deltachat.set_context_callback(self._dc_context, self._process_event)
|
||||||
self._threads = IOThreads(self._dc_context)
|
|
||||||
self._configkeys = self.get_config("sys.config_keys").split()
|
self._configkeys = self.get_config("sys.config_keys").split()
|
||||||
self._imex_completed = threading.Event()
|
self._imex_completed = threading.Event()
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
from deltachat import const
|
from deltachat import const, Account
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from conftest import wait_configuration_progress, wait_successful_IMAP_SMTP_connection
|
from conftest import wait_configuration_progress, wait_successful_IMAP_SMTP_connection
|
||||||
|
|
||||||
|
|
||||||
class TestOfflineAccount:
|
class TestOfflineAccount:
|
||||||
|
def test_wrong_db(self, tmpdir):
|
||||||
|
p = tmpdir.join("hello.db")
|
||||||
|
p.write("123")
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
Account(p.strpath)
|
||||||
|
|
||||||
def test_getinfo(self, acfactory):
|
def test_getinfo(self, acfactory):
|
||||||
ac1 = acfactory.get_unconfigured_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
d = ac1.get_info()
|
d = ac1.get_info()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from __future__ import print_function
|
|||||||
import pytest
|
import pytest
|
||||||
from deltachat import capi, Account, const, set_context_callback, clear_context_callback
|
from deltachat import capi, Account, const, set_context_callback, clear_context_callback
|
||||||
from deltachat.capi import ffi
|
from deltachat.capi import ffi
|
||||||
|
from deltachat.capi import lib
|
||||||
from deltachat.account import EventLogger
|
from deltachat.account import EventLogger
|
||||||
|
|
||||||
|
|
||||||
@@ -23,17 +24,31 @@ def test_dc_close_events():
|
|||||||
evlog.set_timeout(5)
|
evlog.set_timeout(5)
|
||||||
set_context_callback(ctx, lambda ctx, evt_name, data1, data2: evlog(evt_name, data1, data2))
|
set_context_callback(ctx, lambda ctx, evt_name, data1, data2: evlog(evt_name, data1, data2))
|
||||||
capi.lib.dc_close(ctx)
|
capi.lib.dc_close(ctx)
|
||||||
# test that we get events from dc_close
|
def find(info_string):
|
||||||
print(evlog.get_matching("DC_EVENT_INFO", check_error=False))
|
while 1:
|
||||||
print(evlog.get_matching("DC_EVENT_INFO", check_error=False))
|
ev = evlog.get_matching("DC_EVENT_INFO", check_error=False)
|
||||||
print(evlog.get_matching("DC_EVENT_INFO", check_error=False))
|
data2 = ev[2]
|
||||||
print(evlog.get_matching("DC_EVENT_INFO", check_error=False))
|
if info_string in data2:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
print("skipping info event", data2)
|
||||||
|
|
||||||
|
find("disconnecting INBOX-watch")
|
||||||
|
find("disconnecting sentbox-thread")
|
||||||
|
find("disconnecting mvbox-thread")
|
||||||
|
find("disconnecting SMTP")
|
||||||
|
find("Database closed")
|
||||||
|
|
||||||
|
|
||||||
def test_wrong_db(tmpdir):
|
def test_wrong_db(tmpdir):
|
||||||
tmpdir.join("hello.db").write("123")
|
dc_context = ffi.gc(
|
||||||
with pytest.raises(ValueError):
|
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, ffi.NULL),
|
||||||
Account(db_path=tmpdir.strpath)
|
lib.dc_context_unref,
|
||||||
|
)
|
||||||
|
p = tmpdir.join("hello.db")
|
||||||
|
# write an invalid database file
|
||||||
|
p.write("x123" * 10)
|
||||||
|
assert not lib.dc_open(dc_context, p.strpath.encode("ascii"), ffi.NULL)
|
||||||
|
|
||||||
|
|
||||||
def test_event_defines():
|
def test_event_defines():
|
||||||
|
|||||||
@@ -1248,15 +1248,20 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if imap_connected_here {
|
if !success {
|
||||||
// XXX why do we want to disconnect here?
|
// disconnect if configure did not succeed
|
||||||
// context.inbox.read().unwrap().disconnect(context);
|
if imap_connected_here {
|
||||||
info!(context, 0, "Skipping INBOX/IMAP disconnect");
|
// context.inbox.read().unwrap().disconnect(context);
|
||||||
}
|
}
|
||||||
if smtp_connected_here {
|
if smtp_connected_here {
|
||||||
// XXX why do we want to disconnect here?
|
// context.smtp.clone().lock().unwrap().disconnect();
|
||||||
// context.smtp.clone().lock().unwrap().disconnect();
|
}
|
||||||
info!(context, 0, "Skipping SMTP disconnect");
|
} else {
|
||||||
|
assert!(imap_connected_here && smtp_connected_here);
|
||||||
|
info!(
|
||||||
|
context,
|
||||||
|
0, "Keeping IMAP/SMTP connections open after successful configuration"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
dc_loginparam_unref(param);
|
dc_loginparam_unref(param);
|
||||||
dc_loginparam_unref(param_autoconfig);
|
dc_loginparam_unref(param_autoconfig);
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ pub unsafe fn dc_perform_imap_jobs(context: &Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network: libc::c_int) {
|
unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network: libc::c_int) {
|
||||||
// info!(context, 0, "dc_job_perform {} {}", thread, probe_network);
|
|
||||||
let mut select_stmt: *mut sqlite3_stmt;
|
let mut select_stmt: *mut sqlite3_stmt;
|
||||||
let mut job = dc_job_t {
|
let mut job = dc_job_t {
|
||||||
job_id: 0,
|
job_id: 0,
|
||||||
@@ -127,7 +126,6 @@ unsafe fn dc_job_perform(context: &Context, thread: libc::c_int, probe_network:
|
|||||||
let mut tries: libc::c_int = 0i32;
|
let mut tries: libc::c_int = 0i32;
|
||||||
while tries <= 1i32 {
|
while tries <= 1i32 {
|
||||||
job.try_again = 0i32;
|
job.try_again = 0i32;
|
||||||
// info!(context, 0, "dc_job_perform action {}", job.action);
|
|
||||||
match job.action {
|
match job.action {
|
||||||
5901 => {
|
5901 => {
|
||||||
dc_job_do_DC_JOB_SEND(context, &mut job);
|
dc_job_do_DC_JOB_SEND(context, &mut job);
|
||||||
|
|||||||
@@ -1060,7 +1060,7 @@ impl Imap {
|
|||||||
let (sender, receiver) = std::sync::mpsc::channel();
|
let (sender, receiver) = std::sync::mpsc::channel();
|
||||||
let v = self.watch.clone();
|
let v = self.watch.clone();
|
||||||
|
|
||||||
warn!(context, 0, "IMAP-IDLE SPAWNING");
|
info!(context, 0, "IMAP-IDLE SPAWNING");
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let &(ref lock, ref cvar) = &*v;
|
let &(ref lock, ref cvar) = &*v;
|
||||||
if let Some(ref mut session) = &mut *session.lock().unwrap() {
|
if let Some(ref mut session) = &mut *session.lock().unwrap() {
|
||||||
|
|||||||
Reference in New Issue
Block a user