Storage sync before writing

This commit is contained in:
Josh Perez 2021-03-12 12:38:43 -05:00 committed by Josh Perez
parent 0fd0fac262
commit 8dc8a64229
1 changed files with 6 additions and 2 deletions

View File

@ -925,7 +925,7 @@ async function sync(): Promise<void> {
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<void> {
window.log.info('storageService.sync: complete');
}
async function upload(): Promise<void> {
async function upload(fromSync = false): Promise<void> {
if (!isStorageWriteFeatureEnabled()) {
window.log.info(
'storageService.upload: Not starting because the feature is not enabled'
@ -971,6 +971,10 @@ async function upload(): Promise<void> {
return;
}
if (!fromSync) {
await sync();
}
const localManifestVersion = window.storage.get('manifestVersion') || 0;
const version = Number(localManifestVersion) + 1;