Implement restore from backup logs
Summary: This differential implements restore from backup log function on web and native. Backup logs aren't decrypted - I agreed with @michal that log decryption will take place in rust just after downloading log.
Test Plan:
- Temporarily disable backup log encryption. Replace encryptedLogBytes with logBytes in NativeConnectionManager.cpp in persistLog.
- Build native app.
- Use the app, create some drafts.
- Download backup logs from XCode.
- Apply this patch to web: https://gist.github.com/marcinwasowicz/1fd0e17c4808d72467ecf11dca9e0ca3
- Find the first log that creates draft and use button introduced by the patch above to trigger restoration.
- Refresh web app. Ensure draft created on native is there.
To test native:
- Comment out removing backup directory in DatabaseManager::clearSensitiveData().
- Comment out code that encrypts logs.
- Add a call that creates main compaction restore_backup in backup.rs.
- Build the app.
- Create compaction by pressing button in backup menu.
- Create some drafts.
- Log out.
- Download app Documents container from XCode and see how many logs are there.
- Change restore_backup to restore from all logs files that affect drafts.
- Build the app. Log in.
- Press button in backup menu to restore from logs
- See that drafts are recreated.
In order to test conflict handler repeat steps above but do not restore from all logs in step 9. Basically skip log that inserts draft and apply only those that modify it. Ensure no drafts are created but logs in the XCode console appear informing that conflict occurred.
Reviewers: kamil, michal
Reviewed By: kamil, michal
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D10905