mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-07 09:31:31 +01:00
option to allow sync to throw error
This commit is contained in:
parent
e35431f374
commit
669f6ddf93
@ -8,7 +8,7 @@ export abstract class SyncService {
|
|||||||
|
|
||||||
getLastSync: () => Promise<Date>;
|
getLastSync: () => Promise<Date>;
|
||||||
setLastSync: (date: Date) => Promise<any>;
|
setLastSync: (date: Date) => Promise<any>;
|
||||||
fullSync: (forceSync: boolean) => Promise<boolean>;
|
fullSync: (forceSync: boolean, allowThrowOnError?: boolean) => Promise<boolean>;
|
||||||
syncUpsertFolder: (notification: SyncFolderNotification, isEdit: boolean) => Promise<boolean>;
|
syncUpsertFolder: (notification: SyncFolderNotification, isEdit: boolean) => Promise<boolean>;
|
||||||
syncDeleteFolder: (notification: SyncFolderNotification) => Promise<boolean>;
|
syncDeleteFolder: (notification: SyncFolderNotification) => Promise<boolean>;
|
||||||
syncUpsertCipher: (notification: SyncCipherNotification, isEdit: boolean) => Promise<boolean>;
|
syncUpsertCipher: (notification: SyncCipherNotification, isEdit: boolean) => Promise<boolean>;
|
||||||
|
@ -61,7 +61,7 @@ export class SyncService implements SyncServiceAbstraction {
|
|||||||
await this.storageService.save(Keys.lastSyncPrefix + userId, date.toJSON());
|
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();
|
this.syncStarted();
|
||||||
const isAuthenticated = await this.userService.isAuthenticated();
|
const isAuthenticated = await this.userService.isAuthenticated();
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
@ -95,7 +95,11 @@ export class SyncService implements SyncServiceAbstraction {
|
|||||||
await this.setLastSync(now);
|
await this.setLastSync(now);
|
||||||
return this.syncCompleted(true);
|
return this.syncCompleted(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return this.syncCompleted(false);
|
if (allowThrowOnError) {
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
|
return this.syncCompleted(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user