From 8dc8a64229b935777f203f22d769f9dd2a4a3568 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Fri, 12 Mar 2021 12:38:43 -0500 Subject: [PATCH] Storage sync before writing --- ts/services/storage.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/services/storage.ts b/ts/services/storage.ts index cd21ceb448..ee9e47de46 100644 --- a/ts/services/storage.ts +++ b/ts/services/storage.ts @@ -925,7 +925,7 @@ async function sync(): Promise { const hasConflicts = await processManifest(manifest); if (hasConflicts) { - await upload(); + await upload(true); } // We now know that we've successfully completed a storage service fetch @@ -947,7 +947,7 @@ async function sync(): Promise { window.log.info('storageService.sync: complete'); } -async function upload(): Promise { +async function upload(fromSync = false): Promise { if (!isStorageWriteFeatureEnabled()) { window.log.info( 'storageService.upload: Not starting because the feature is not enabled' @@ -971,6 +971,10 @@ async function upload(): Promise { return; } + if (!fromSync) { + await sync(); + } + const localManifestVersion = window.storage.get('manifestVersion') || 0; const version = Number(localManifestVersion) + 1;