Skip to content

Commit

Permalink
Merge pull request #105341 from microsoft/sandy081/fix104834
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 authored Aug 25, 2020
2 parents d735393 + e6e146b commit a047975
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export abstract class AbstractSynchroniser extends Disposable {
this.logService.info(`${this.syncResourceLogLabel}: Failed to synchronize ${this.syncResourceLogLabel} as there is a new local version available. Synchronizing again...`);
return this.performSync(remoteUserData, lastSyncUserData, apply);

case UserDataSyncErrorCode.Conflict:
case UserDataSyncErrorCode.PreconditionFailed:
// Rejected as there is a new remote version. Syncing again...
this.logService.info(`${this.syncResourceLogLabel}: Failed to synchronize as there is a new remote version available. Synchronizing again...`);
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/userDataSync/common/userDataSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const HEADER_EXECUTION_ID = 'X-Execution-Id';
export enum UserDataSyncErrorCode {
// Client Errors (>= 400 )
Unauthorized = 'Unauthorized', /* 401 */
Conflict = 'Conflict', /* 409 */
Gone = 'Gone', /* 410 */
PreconditionFailed = 'PreconditionFailed', /* 412 */
TooLarge = 'TooLarge', /* 413 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ export class UserDataSyncStoreService extends Disposable implements IUserDataSyn

this._onTokenSucceed.fire();

if (context.res.statusCode === 409) {
throw new UserDataSyncStoreError(`${options.type} request '${options.url?.toString()}' failed because of Conflict (409). There is new data exists for this resource. Make the request again with latest data.`, UserDataSyncErrorCode.Conflict, operationId);
}

if (context.res.statusCode === 410) {
throw new UserDataSyncStoreError(`${options.type} request '${options.url?.toString()}' failed because the requested resource is not longer available (410).`, UserDataSyncErrorCode.Gone, operationId);
}
Expand Down

0 comments on commit a047975

Please sign in to comment.