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

View file

@ -925,7 +925,7 @@ async function sync(): Promise<void> {
const hasConflicts = await processManifest(manifest); const hasConflicts = await processManifest(manifest);
if (hasConflicts) { if (hasConflicts) {
await upload(); await upload(true);
} }
// We now know that we've successfully completed a storage service fetch // 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'); window.log.info('storageService.sync: complete');
} }
async function upload(): Promise<void> { async function upload(fromSync = false): Promise<void> {
if (!isStorageWriteFeatureEnabled()) { if (!isStorageWriteFeatureEnabled()) {
window.log.info( window.log.info(
'storageService.upload: Not starting because the feature is not enabled' 'storageService.upload: Not starting because the feature is not enabled'
@ -971,6 +971,10 @@ async function upload(): Promise<void> {
return; return;
} }
if (!fromSync) {
await sync();
}
const localManifestVersion = window.storage.get('manifestVersion') || 0; const localManifestVersion = window.storage.get('manifestVersion') || 0;
const version = Number(localManifestVersion) + 1; const version = Number(localManifestVersion) + 1;