From 669f6ddf93bbfe8acd18a4834fff5e1c7f9c91ba Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 15 Oct 2019 11:06:55 -0400 Subject: [PATCH] option to allow sync to throw error --- src/abstractions/sync.service.ts | 2 +- src/services/sync.service.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/abstractions/sync.service.ts b/src/abstractions/sync.service.ts index 264e6ecbf9..ad6eb498e8 100644 --- a/src/abstractions/sync.service.ts +++ b/src/abstractions/sync.service.ts @@ -8,7 +8,7 @@ export abstract class SyncService { getLastSync: () => Promise; setLastSync: (date: Date) => Promise; - fullSync: (forceSync: boolean) => Promise; + fullSync: (forceSync: boolean, allowThrowOnError?: boolean) => Promise; syncUpsertFolder: (notification: SyncFolderNotification, isEdit: boolean) => Promise; syncDeleteFolder: (notification: SyncFolderNotification) => Promise; syncUpsertCipher: (notification: SyncCipherNotification, isEdit: boolean) => Promise; diff --git a/src/services/sync.service.ts b/src/services/sync.service.ts index 6db32a6e6f..4e98d785ee 100644 --- a/src/services/sync.service.ts +++ b/src/services/sync.service.ts @@ -61,7 +61,7 @@ export class SyncService implements SyncServiceAbstraction { await this.storageService.save(Keys.lastSyncPrefix + userId, date.toJSON()); } - async fullSync(forceSync: boolean): Promise { + async fullSync(forceSync: boolean, allowThrowOnError = false): Promise { this.syncStarted(); const isAuthenticated = await this.userService.isAuthenticated(); if (!isAuthenticated) { @@ -95,7 +95,11 @@ export class SyncService implements SyncServiceAbstraction { await this.setLastSync(now); return this.syncCompleted(true); } catch (e) { - return this.syncCompleted(false); + if (allowThrowOnError) { + throw e; + } else { + return this.syncCompleted(false); + } } }