提交 66cd1d8e 编写于 作者: S Sandeep Somavarapu

Fix #90624

上级 86abd4e9
...@@ -91,7 +91,7 @@ export abstract class AbstractSynchroniser extends Disposable { ...@@ -91,7 +91,7 @@ export abstract class AbstractSynchroniser extends Disposable {
protected get enabled(): boolean { return this.userDataSyncEnablementService.isResourceEnabled(this.resourceKey); } protected get enabled(): boolean { return this.userDataSyncEnablementService.isResourceEnabled(this.resourceKey); }
async sync(ref?: string): Promise<void> { async sync(ref?: string, donotUseLastSyncUserData?: boolean): Promise<void> {
if (!this.enabled) { if (!this.enabled) {
this.logService.info(`${this.source}: Skipped synchronizing ${this.source.toLowerCase()} as it is disabled.`); this.logService.info(`${this.source}: Skipped synchronizing ${this.source.toLowerCase()} as it is disabled.`);
return; return;
...@@ -108,7 +108,7 @@ export abstract class AbstractSynchroniser extends Disposable { ...@@ -108,7 +108,7 @@ export abstract class AbstractSynchroniser extends Disposable {
this.logService.trace(`${this.source}: Started synchronizing ${this.source.toLowerCase()}...`); this.logService.trace(`${this.source}: Started synchronizing ${this.source.toLowerCase()}...`);
this.setStatus(SyncStatus.Syncing); this.setStatus(SyncStatus.Syncing);
const lastSyncUserData = await this.getLastSyncUserData(); const lastSyncUserData = donotUseLastSyncUserData ? null : await this.getLastSyncUserData();
const remoteUserData = ref && lastSyncUserData && lastSyncUserData.ref === ref ? lastSyncUserData : await this.getRemoteUserData(lastSyncUserData); const remoteUserData = ref && lastSyncUserData && lastSyncUserData.ref === ref ? lastSyncUserData : await this.getRemoteUserData(lastSyncUserData);
if (remoteUserData.syncData && remoteUserData.syncData.version > this.version) { if (remoteUserData.syncData && remoteUserData.syncData.version > this.version) {
...@@ -117,7 +117,19 @@ export abstract class AbstractSynchroniser extends Disposable { ...@@ -117,7 +117,19 @@ export abstract class AbstractSynchroniser extends Disposable {
throw new UserDataSyncError(localize('incompatible', "Cannot sync {0} as its version {1} is not compatible with cloud {2}", this.source, this.version, remoteUserData.syncData.version), UserDataSyncErrorCode.Incompatible, this.source); throw new UserDataSyncError(localize('incompatible', "Cannot sync {0} as its version {1} is not compatible with cloud {2}", this.source, this.version, remoteUserData.syncData.version), UserDataSyncErrorCode.Incompatible, this.source);
} }
return this.doSync(remoteUserData, lastSyncUserData); try {
await this.doSync(remoteUserData, lastSyncUserData);
} catch (e) {
if (e instanceof UserDataSyncError) {
switch (e.code) {
case UserDataSyncErrorCode.RemotePreconditionFailed:
// Rejected as there is a new remote version. Syncing again,
this.logService.info(`${this.source}: Failed to synchronize as there is a new remote version available. Synchronizing again...`);
return this.sync(undefined, true);
}
}
throw e;
}
} }
async hasPreviouslySynced(): Promise<boolean> { async hasPreviouslySynced(): Promise<boolean> {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { UserDataSyncError, UserDataSyncErrorCode, SyncStatus, IUserDataSyncStoreService, ISyncExtension, IUserDataSyncLogService, IUserDataSynchroniser, SyncSource, ResourceKey, IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync'; import { SyncStatus, IUserDataSyncStoreService, ISyncExtension, IUserDataSyncLogService, IUserDataSynchroniser, SyncSource, ResourceKey, IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
...@@ -154,11 +154,6 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse ...@@ -154,11 +154,6 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
await this.apply(previewResult); await this.apply(previewResult);
} catch (e) { } catch (e) {
this.setStatus(SyncStatus.Idle); this.setStatus(SyncStatus.Idle);
if (e instanceof UserDataSyncError && e.code === UserDataSyncErrorCode.RemotePreconditionFailed) {
// Rejected as there is a new remote version. Syncing again,
this.logService.info('Extensions: Failed to synchronize extensions as there is a new remote version available. Synchronizing again...');
return this.sync();
}
throw e; throw e;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { UserDataSyncError, UserDataSyncErrorCode, SyncStatus, IUserDataSyncStoreService, IUserDataSyncLogService, IGlobalState, SyncSource, IUserDataSynchroniser, ResourceKey, IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync'; import { SyncStatus, IUserDataSyncStoreService, IUserDataSyncLogService, IGlobalState, SyncSource, IUserDataSynchroniser, ResourceKey, IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
import { VSBuffer } from 'vs/base/common/buffer'; import { VSBuffer } from 'vs/base/common/buffer';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
...@@ -131,11 +131,6 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs ...@@ -131,11 +131,6 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
this.logService.trace('UI State: Finished synchronizing ui state.'); this.logService.trace('UI State: Finished synchronizing ui state.');
} catch (e) { } catch (e) {
this.setStatus(SyncStatus.Idle); this.setStatus(SyncStatus.Idle);
if (e instanceof UserDataSyncError && e.code === UserDataSyncErrorCode.RemotePreconditionFailed) {
// Rejected as there is a new remote version. Syncing again,
this.logService.info('UI State: Failed to synchronize ui state as there is a new remote version available. Synchronizing again...');
return this.sync();
}
throw e; throw e;
} finally { } finally {
this.setStatus(SyncStatus.Idle); this.setStatus(SyncStatus.Idle);
......
...@@ -180,10 +180,6 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem ...@@ -180,10 +180,6 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem
this.setStatus(SyncStatus.Idle); this.setStatus(SyncStatus.Idle);
if (e instanceof UserDataSyncError) { if (e instanceof UserDataSyncError) {
switch (e.code) { switch (e.code) {
case UserDataSyncErrorCode.RemotePreconditionFailed:
// Rejected as there is a new remote version. Syncing again,
this.logService.info('Keybindings: Failed to synchronize keybindings as there is a new remote version available. Synchronizing again...');
return this.sync();
case UserDataSyncErrorCode.LocalPreconditionFailed: case UserDataSyncErrorCode.LocalPreconditionFailed:
// Rejected as there is a new local version. Syncing again. // Rejected as there is a new local version. Syncing again.
this.logService.info('Keybindings: Failed to synchronize keybindings as there is a new local version available. Synchronizing again...'); this.logService.info('Keybindings: Failed to synchronize keybindings as there is a new local version available. Synchronizing again...');
......
...@@ -243,10 +243,6 @@ export class SettingsSynchroniser extends AbstractJsonFileSynchroniser implement ...@@ -243,10 +243,6 @@ export class SettingsSynchroniser extends AbstractJsonFileSynchroniser implement
this.setStatus(SyncStatus.Idle); this.setStatus(SyncStatus.Idle);
if (e instanceof UserDataSyncError) { if (e instanceof UserDataSyncError) {
switch (e.code) { switch (e.code) {
case UserDataSyncErrorCode.RemotePreconditionFailed:
// Rejected as there is a new remote version. Syncing again,
this.logService.info('Settings: Failed to synchronize settings as there is a new remote version available. Synchronizing again...');
return this.sync();
case UserDataSyncErrorCode.LocalPreconditionFailed: case UserDataSyncErrorCode.LocalPreconditionFailed:
// Rejected as there is a new local version. Syncing again. // Rejected as there is a new local version. Syncing again.
this.logService.info('Settings: Failed to synchronize settings as there is a new local version available. Synchronizing again...'); this.logService.info('Settings: Failed to synchronize settings as there is a new local version available. Synchronizing again...');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册