Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3179774
D11947.id39940.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11947.id39940.diff
View Options
diff --git a/web/redux/persist-constants.js b/web/redux/persist-constants.js
--- a/web/redux/persist-constants.js
+++ b/web/redux/persist-constants.js
@@ -3,5 +3,6 @@
const rootKey = 'root';
const rootKeyPrefix = 'persist:';
const completeRootKey = `${rootKeyPrefix}${rootKey}`;
+const storeVersion = 75;
-export { rootKey, rootKeyPrefix, completeRootKey };
+export { rootKey, rootKeyPrefix, completeRootKey, storeVersion };
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -46,7 +46,7 @@
handleReduxMigrationFailure,
persistWhitelist,
} from './handle-redux-migration-failure.js';
-import { rootKey, rootKeyPrefix } from './persist-constants.js';
+import { rootKey, rootKeyPrefix, storeVersion } from './persist-constants.js';
import type { AppState } from './redux-setup.js';
import { unshimClientDB } from './unshim-utils.js';
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
@@ -523,7 +523,7 @@
migrations,
migrateStorageToSQLite,
): any),
- version: 75,
+ version: storeVersion,
transforms: [messageStoreMessagesBlocklistTransform, keyserverStoreTransform],
};
diff --git a/web/shared-worker/worker/backup.js b/web/shared-worker/worker/backup.js
--- a/web/shared-worker/worker/backup.js
+++ b/web/shared-worker/worker/backup.js
@@ -3,13 +3,17 @@
import backupService from 'lib/facts/backup-service.js';
import { decryptCommon } from 'lib/media/aes-crypto-utils-common.js';
import type { AuthMetadata } from 'lib/shared/identity-client-context.js';
+import { syncedMetadataNames } from 'lib/types/synced-metadata-types.js';
import { getProcessingStoreOpsExceptionMessage } from './process-operations.js';
import {
BackupClient,
RequestedData,
} from '../../backup-client-wasm/wasm/backup-client-wasm.js';
-import { completeRootKey } from '../../redux/persist-constants.js';
+import {
+ completeRootKey,
+ storeVersion,
+} from '../../redux/persist-constants.js';
import type { EmscriptenModule } from '../types/module.js';
import type { SQLiteQueryExecutor } from '../types/sqlite-query-executor.js';
import { COMM_SQLITE_BACKUP_RESTORE_DATABASE_PATH } from '../utils/constants.js';
@@ -55,6 +59,13 @@
backupDataKey,
);
+ const backupVersion = sqliteQueryExecutor
+ .getAllSyncedMetadata()
+ .find(entry => entry.name === syncedMetadataNames.DB_VERSION)?.data;
+ if (!backupVersion || parseInt(backupVersion) > (storeVersion ?? 0)) {
+ throw new Error(`Incompatible backup version ${backupVersion ?? -1}`);
+ }
+
sqliteQueryExecutor.setPersistStorageItem(
completeRootKey,
reduxPersistData,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 3:33 AM (18 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2448246
Default Alt Text
D11947.id39940.diff (2 KB)
Attached To
Mode
D11947: [web] Check backup version when restoring
Attached
Detach File
Event Timeline
Log In to Comment