Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for backup transfer #6027

Merged
merged 5 commits into from
Oct 5, 2024
Merged

Fixes for backup transfer #6027

merged 5 commits into from
Oct 5, 2024

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Oct 4, 2024

Closes #5993

fix: make it possible to cancel ongoing backup transfer

Before this change clicking "cancel" did not actually cancel the backup transfer if connection has already been established.

fix: smooth progress bar for backup transfer

Before this change progress bar only started
when database is already transferred.
Database is usually the largest file
in the whole transfer, so the transfer appears
to be stuck for the sender.

With this change progress bar
starts for backup export
as soon as connection is received
and counts bytes transferred over the connection
using AsyncWrite wrapper.

Similarly for backup import,
AsyncRead wrapper counts the bytes
received and emits progress events.

With this change Delta Chat desktop, from which I'm transferring, immediately shows the progress bar:
transferring

fix: make backup reception cancellable by stopping ongoing process

This is already documented in JSON-RPC API,
but in fact ongoing process was not allocated.

fix: emit progress 0 if get_backup() fails

Otherwise receiver gets stuck if the sender cancels backup transfer.

@link2xt link2xt changed the title fix: start progress bar for outgoing backup transfer early Fixes for sender side of backup transfer Oct 5, 2024
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch 2 times, most recently from bc15715 to eda7140 Compare October 5, 2024 08:42
@link2xt link2xt marked this pull request as draft October 5, 2024 09:00
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch 3 times, most recently from 7a77398 to 69fbf4b Compare October 5, 2024 09:44
@link2xt link2xt marked this pull request as ready for review October 5, 2024 09:44
@link2xt
Copy link
Collaborator Author

link2xt commented Oct 5, 2024

There is a corresponding Android PR with progress bar fixes: deltachat/deltachat-android#3333

@link2xt link2xt force-pushed the link2xt/imex-progress-events branch from 69fbf4b to bb4d65e Compare October 5, 2024 09:51
@link2xt link2xt requested a review from adbenitez October 5, 2024 10:03
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch from 5c20c6a to 9f4a329 Compare October 5, 2024 15:38
).race(async {
drop_token.cancelled().await;
Err(format_err!("Backup provider dropped"))
}).await {
warn!(context, "Error while handling backup connection: {err:#}.");
Copy link
Collaborator

@Hocuri Hocuri Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, if the transfer is cancelled during endpoint.accept(..), we do context.emit_event(EventType::ImexProgress(0)), and write nothing to the log.

If the transfer is cancelled during handle_connection(..), we write a message to the log, don't emit an event, and continue with the next iteration of the loop, (i.e. try to call endpoint.accept(..)) again. (this was fixed)

This seems surprising?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by emitting progress 0. Cancellation during transfer is still logged as a warning unlike cancellation of accept loop, but it is just logging and not shown in the UI anyway.

src/imex/transfer.rs Outdated Show resolved Hide resolved
src/imex.rs Outdated Show resolved Hide resolved
src/imex.rs Show resolved Hide resolved
src/imex.rs Show resolved Hide resolved
src/imex.rs Show resolved Hide resolved
src/imex.rs Outdated Show resolved Hide resolved
src/imex.rs Outdated Show resolved Hide resolved
src/imex/transfer.rs Outdated Show resolved Hide resolved
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch from fe912eb to c9a9cd6 Compare October 5, 2024 17:14
Hocuri added a commit to deltachat/deltachat-android that referenced this pull request Oct 5, 2024
With deltachat/deltachat-core-rust#6027, when
exporting a backup, the counter stays at 0% while running housekeeping
and vacuuming the database, which takes 10 seconds on my device.

Showing "One moment... 0%" for 10 seconds (or longer on slower devices /
with bigger accounts) might make users think that it's not working and
abort the process. So, instead, simply show "One moment..." until the
progress reaches 1%.
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch from c9a9cd6 to 582b379 Compare October 5, 2024 17:29
Before this change progress bar only started
when database is already transferred.
Database is usually the largest file
in the whole transfer, so the transfer appears
to be stuck for the sender.

With this change progress bar
starts for backup export
as soon as connection is received
and counts bytes transferred over the connection
using AsyncWrite wrapper.

Similarly for backup import,
AsyncRead wrapper counts the bytes
received and emits progress events.
This is already documented in JSON-RPC API,
but in fact ongoing process was not allocated.
@link2xt link2xt force-pushed the link2xt/imex-progress-events branch from 582b379 to 99a8a40 Compare October 5, 2024 17:36
Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉🎉🎉 More fixed bugs!

@link2xt link2xt merged commit 2cb8b53 into main Oct 5, 2024
37 checks passed
@link2xt link2xt deleted the link2xt/imex-progress-events branch October 5, 2024 17:58
Hocuri added a commit to deltachat/deltachat-android that referenced this pull request Oct 5, 2024
With deltachat/deltachat-core-rust#6027, when
exporting a backup, the counter stays at 0% while running housekeeping
and vacuuming the database, which takes 10 seconds on my device.

Showing "One moment... 0%" for 10 seconds (or longer on slower devices /
with bigger accounts) might make users think that it's not working and
abort the process. So, instead, simply show "One moment..." until the
progress reaches 1%.
@link2xt link2xt changed the title Fixes for sender side of backup transfer Fixes for backup transfer Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing backup transfer with core 1.142.12
2 participants