Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
option to allow sync to throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Oct 15, 2019
1 parent e35431f commit 669f6dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/abstractions/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class SyncService {

getLastSync: () => Promise<Date>;
setLastSync: (date: Date) => Promise<any>;
fullSync: (forceSync: boolean) => Promise<boolean>;
fullSync: (forceSync: boolean, allowThrowOnError?: boolean) => Promise<boolean>;
syncUpsertFolder: (notification: SyncFolderNotification, isEdit: boolean) => Promise<boolean>;
syncDeleteFolder: (notification: SyncFolderNotification) => Promise<boolean>;
syncUpsertCipher: (notification: SyncCipherNotification, isEdit: boolean) => Promise<boolean>;
Expand Down
8 changes: 6 additions & 2 deletions src/services/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SyncService implements SyncServiceAbstraction {
await this.storageService.save(Keys.lastSyncPrefix + userId, date.toJSON());
}

async fullSync(forceSync: boolean): Promise<boolean> {
async fullSync(forceSync: boolean, allowThrowOnError = false): Promise<boolean> {
this.syncStarted();
const isAuthenticated = await this.userService.isAuthenticated();
if (!isAuthenticated) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 669f6dd

Please sign in to comment.