Run storage service on link
This commit is contained in:
parent
3050a314f9
commit
08eb4fc168
3 changed files with 19 additions and 1 deletions
|
@ -1368,6 +1368,7 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
async function runStorageService() {
|
||||
StorageService.enableStorageService();
|
||||
StorageService.runStorageServiceSyncJob();
|
||||
}
|
||||
|
||||
async function start() {
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
encryptProfile,
|
||||
decryptProfile,
|
||||
deriveMasterKeyFromGroupV1,
|
||||
deriveStorageServiceKey,
|
||||
} from '../Crypto';
|
||||
import {
|
||||
mergeAccountRecord,
|
||||
|
@ -1725,7 +1726,18 @@ async function sync(
|
|||
ignoreConflicts = false
|
||||
): Promise<Proto.ManifestRecord | undefined> {
|
||||
if (!window.storage.get('storageKey')) {
|
||||
throw new Error('storageService.sync: Cannot start; no storage key!');
|
||||
const masterKeyBase64 = window.storage.get('masterKey');
|
||||
if (!masterKeyBase64) {
|
||||
throw new Error(
|
||||
'storageService.sync: Cannot start; no storage or master key!'
|
||||
);
|
||||
}
|
||||
|
||||
const masterKey = Bytes.fromBase64(masterKeyBase64);
|
||||
const storageKeyBase64 = Bytes.toBase64(deriveStorageServiceKey(masterKey));
|
||||
await window.storage.put('storageKey', storageKeyBase64);
|
||||
|
||||
log.warn('storageService.sync: fixed storage key');
|
||||
}
|
||||
|
||||
log.info(
|
||||
|
|
|
@ -32,6 +32,7 @@ import {
|
|||
getRandomBytes,
|
||||
decryptDeviceName,
|
||||
encryptDeviceName,
|
||||
deriveStorageServiceKey,
|
||||
} from '../Crypto';
|
||||
import {
|
||||
generateKeyPair,
|
||||
|
@ -1237,6 +1238,10 @@ export default class AccountManager extends EventTarget {
|
|||
}
|
||||
if (masterKey) {
|
||||
await storage.put('masterKey', Bytes.toBase64(masterKey));
|
||||
await storage.put(
|
||||
'storageKey',
|
||||
Bytes.toBase64(deriveStorageServiceKey(masterKey))
|
||||
);
|
||||
}
|
||||
|
||||
await storage.put('read-receipt-setting', Boolean(readReceipts));
|
||||
|
|
Loading…
Reference in a new issue