From 740f43a2d67ea435c06480fc04d34b710778c78e Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 17 Jul 2023 09:03:59 +0000 Subject: [PATCH 1/4] fix: do not resync IMAP after initial configuration If there was no previous `configured_addr`, then there is no need to run IMAP resync. --- python/examples/test_examples.py | 4 ---- python/src/deltachat/testplugin.py | 7 ------- src/configure.rs | 9 ++++++--- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/python/examples/test_examples.py b/python/examples/test_examples.py index 6e4f6ef256..ca8e48b696 100644 --- a/python/examples/test_examples.py +++ b/python/examples/test_examples.py @@ -24,8 +24,6 @@ def test_echo_quit_plugin(acfactory, lp): lp.sec("creating a temp account to contact the bot") (ac1,) = acfactory.get_online_accounts(1) - botproc.await_resync() - lp.sec("sending a message to the bot") bot_contact = ac1.create_contact(botproc.addr) bot_chat = bot_contact.create_chat() @@ -54,8 +52,6 @@ def test_group_tracking_plugin(acfactory, lp): ac1.add_account_plugin(FFIEventLogger(ac1)) ac2.add_account_plugin(FFIEventLogger(ac2)) - botproc.await_resync() - lp.sec("creating bot test group with bot") bot_contact = ac1.create_contact(botproc.addr) ch = ac1.create_group_chat("bot test group") diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index 3dee022bf3..d736984b6c 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -682,13 +682,6 @@ def fnmatch_lines(self, pattern_lines): print("+++IGN:", line) ignored.append(line) - def await_resync(self): - self.fnmatch_lines( - """ - *Resync: collected * message IDs in folder INBOX* - """, - ) - @pytest.fixture() def tmp_db_path(tmpdir): diff --git a/src/configure.rs b/src/configure.rs index 42922f1452..59f7a02ab0 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -462,9 +462,12 @@ async fn configure(ctx: &Context, param: &mut LoginParam) -> Result<()> { progress!(ctx, 910); - if ctx.get_config(Config::ConfiguredAddr).await?.as_deref() != Some(¶m.addr) { - // Switched account, all server UIDs we know are invalid - job::schedule_resync(ctx).await?; + if let Some(configured_addr) = ctx.get_config(Config::ConfiguredAddr).await? { + if configured_addr != param.addr { + // Switched account, all server UIDs we know are invalid + info!(ctx, "Scheduling resync because the address has changed."); + job::schedule_resync(ctx).await?; + } } // the trailing underscore is correct From 1bd307a26adb28273693dd04af5f11fb34254122 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 17 Jul 2023 15:00:10 +0000 Subject: [PATCH 2/4] api(deltachat-rpc-client): add Account.{import,export}_backup methods --- deltachat-rpc-client/src/deltachat_rpc_client/account.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/account.py b/deltachat-rpc-client/src/deltachat_rpc_client/account.py index c3f29995c9..ce5d52f9a2 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/account.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/account.py @@ -259,3 +259,11 @@ async def get_fresh_messages_in_arrival_order(self) -> List[Message]: ) fresh_msg_ids = sorted(await self._rpc.get_fresh_msgs(self.id)) return [Message(self, msg_id) for msg_id in fresh_msg_ids] + + async def export_backup(self, path, passphrase: str = "") -> None: + """Export backup.""" + await self._rpc.export_backup(self.id, str(path), passphrase) + + async def import_backup(self, path, passphrase: str = "") -> None: + """Import backup.""" + await self._rpc.import_backup(self.id, str(path), passphrase) From 82c0058129f3e2bf982d673578f4b0fb52bd2158 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 17 Jul 2023 14:48:11 +0000 Subject: [PATCH 3/4] test: add basic import/export test for async python --- deltachat-rpc-client/tests/test_something.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 20f7acaae2..72c8630f95 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -335,3 +335,13 @@ async def test_wait_next_messages(acfactory) -> None: assert len(next_messages) == 1 snapshot = await next_messages[0].get_snapshot() assert snapshot.text == "Hello!" + + +@pytest.mark.asyncio() +async def test_import_export(acfactory, tmp_path) -> None: + alice = await acfactory.new_configured_account() + await alice.export_backup(tmp_path) + + files = list(tmp_path.glob("*.tar")) + alice2 = await acfactory.get_unconfigured_account() + await alice2.import_backup(files[0]) From 0a50bad555c73fd8b476a9713c34d4415faacb43 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 17 Jul 2023 16:31:02 +0000 Subject: [PATCH 4/4] fix(deltachat-rpc-server): update tokio-tar to fix backup import tokio-tar 0.3.0 prints message "create_dir_all ..." to stdout during import. tokio-tar 0.3.1 has removed this debug output which broke stdio JSON-RPC protocol. --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 735db14604..6030233cfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4958,14 +4958,14 @@ dependencies = [ [[package]] name = "tokio-tar" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50188549787c32c1c3d9c8c71ad7e003ccf2f102489c5a96e385c84760477f4" +checksum = "9d5714c010ca3e5c27114c1cdeb9d14641ace49874aa5626d7149e47aedace75" dependencies = [ "filetime", "futures-core", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "tokio", "tokio-stream", "xattr", @@ -5778,9 +5778,9 @@ dependencies = [ [[package]] name = "xattr" -version = "0.2.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" +checksum = "ea263437ca03c1522846a4ddafbca2542d0ad5ed9b784909d4b27b76f62bc34a" dependencies = [ "libc", ]