Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3306086
D12016.id40935.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12016.id40935.diff
View Options
diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js
--- a/native/backup/use-client-backup.js
+++ b/native/backup/use-client-backup.js
@@ -7,10 +7,16 @@
import type { SIWEBackupSecrets } from 'lib/types/siwe-types.js';
import type { CurrentUserInfo } from 'lib/types/user-types';
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
+import { runMigrations } from 'lib/utils/migration-utils.js';
import { fetchNativeKeychainCredentials } from '../account/native-credentials.js';
import { commCoreModule } from '../native-modules.js';
-import { persistConfig } from '../redux/persist.js';
+import { defaultState } from '../redux/default-state.js';
+import {
+ legacyMigrations,
+ migrations,
+ persistConfig,
+} from '../redux/persist.js';
import { useSelector } from '../redux/redux-utils.js';
type SIWEBackupData = {
@@ -114,6 +120,24 @@
persistConfig.version.toString(),
);
+ const backupVersion = await commCoreModule.getSyncedDatabaseVersion();
+ const backupVersionNumber = parseInt(backupVersion);
+ console.info('Running backup migrations...');
+ await runMigrations(
+ legacyMigrations,
+ migrations,
+ {
+ ...defaultState,
+ _persist: {
+ version: backupVersionNumber,
+ rehydrated: true,
+ },
+ },
+ backupVersionNumber,
+ persistConfig.version,
+ process.env.NODE_ENV !== 'production',
+ );
+
console.info('Backup restored.');
return;
}, [
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -108,6 +108,8 @@
convertMessageStoreThreadsToNewIDSchema,
convertThreadStoreThreadInfosToNewIDSchema,
createAsyncMigrate,
+ type LegacyMigrationManifest,
+ type MigrationManifest,
} from 'lib/utils/migration-utils.js';
import { entries } from 'lib/utils/objects.js';
import {
@@ -138,11 +140,12 @@
import { unshimClientDB } from './unshim-utils.js';
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import { commCoreModule } from '../native-modules.js';
+import type { NavInfo } from '../navigation/default-state.js';
import { defaultDeviceCameraInfo } from '../types/camera.js';
import { isTaskCancelledError } from '../utils/error-handling.js';
import { defaultURLPrefix } from '../utils/url-utils.js';
-const legacyMigrations = {
+const legacyMigrations: LegacyMigrationManifest<NavInfo, AppState> = {
[1]: (state: AppState) => ({
...state,
notifPermissionAlertInfo: defaultAlertInfo,
@@ -1339,7 +1342,7 @@
{ whitelist: ['reportStore'] },
);
-const migrations = {
+const migrations: MigrationManifest<NavInfo, AppState> = {
// This migration doesn't change the store but sets a persisted version
// in the DB
[75]: (state: AppState) => ({
@@ -1387,4 +1390,11 @@
return storedPersistor;
}
-export { persistConfig, codeVersion, setPersistor, getPersistor };
+export {
+ persistConfig,
+ codeVersion,
+ setPersistor,
+ getPersistor,
+ migrations,
+ legacyMigrations,
+};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 6:18 PM (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2539898
Default Alt Text
D12016.id40935.diff (3 KB)
Attached To
Mode
D12016: [native] Run backup migrations
Attached
Detach File
Event Timeline
Log In to Comment