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

Identity reset backup fixes #3790

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Conversation

stefanceriu
Copy link
Member

This PR handles 2 different issues:

  1. The normal backups().disable method does not delete the remote backup if the backups haven't been setup yet locally
  2. and it doesn't throw an error or reset the backup state when that happens

We've introduced a new delete_backup method what will delete remote backups and that can be used from the identity reset flows to correctly setup the fresh session.

@stefanceriu stefanceriu requested a review from a team as a code owner August 1, 2024 15:29
@stefanceriu stefanceriu requested review from jmartinesp and poljar and removed request for a team and jmartinesp August 1, 2024 15:29
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.07%. Comparing base (1ca4377) to head (1402382).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3790      +/-   ##
==========================================
+ Coverage   84.06%   84.07%   +0.01%     
==========================================
  Files         261      261              
  Lines       27352    27365      +13     
==========================================
+ Hits        22993    23008      +15     
+ Misses       4359     4357       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Looking good but needs a bit more polish.

@@ -423,6 +423,39 @@ impl Backups {
Ok(())
}

/// Deletes the current backup version from the server
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this need a bit more of a warning, feel free to add some ⚠️ symbols. We should probably also link to the safer, disable() mehod from, and to, this one.

As usual, an doc example wouldn't hurt either.


olm_machine.backup_machine().disable_backup().await?;

self.set_state(BackupState::Unknown);
Copy link
Contributor

Choose a reason for hiding this comment

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

Both the OK and error case go into the Unknown state, so you can just have one set_state() in the main part of the function, just before you return the result.

@@ -780,11 +780,15 @@ async fn test_reset_identity() {
assert_eq!(client.encryption().recovery().state(), RecoveryState::Enabled);

// Disabling backups
Mock::given(method("DELETE"))
.and(path("_matrix/client/r0/room_keys/version/1"))
Mock::given(method("GET"))
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not quite testing the happy path if you never need to mock the DELETE endpoint. You're returning a 404 on the GET version call, so the SDK concludes that a backup doesn't exist and doesn't need to be deleted.

A valid test, but if we had a test for the happy path, which does need to delete the backup as well.

@stefanceriu stefanceriu force-pushed the stefan/identityResetBackupFixes branch from 294c424 to 50973fe Compare August 2, 2024 11:09
@stefanceriu stefanceriu requested a review from poljar August 2, 2024 11:26
…s if they weren't previously enabled locally

- also change back the state from `disabling` to `unknown`
…ed locally, resulting in conflicts and failing to correctly setup the newly reset session
@stefanceriu stefanceriu force-pushed the stefan/identityResetBackupFixes branch from 50973fe to 1402382 Compare August 2, 2024 12:09
@stefanceriu stefanceriu enabled auto-merge (rebase) August 2, 2024 12:09
@stefanceriu stefanceriu merged commit 1160383 into main Aug 2, 2024
40 checks passed
@stefanceriu stefanceriu deleted the stefan/identityResetBackupFixes branch August 2, 2024 12:25
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.

2 participants