Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Mar 24, 2022
1 parent c21e347 commit ee0c8c4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/vs/platform/userDataSync/common/abstractSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,14 @@ export abstract class AbstractSynchroniser extends Disposable implements IUserDa
return this.configurationService.getValue(USER_DATA_SYNC_CONFIGURATION_SCOPE);
}

protected hasToUpdateLastSyncUserData(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null): boolean {
if (lastSyncUserData === null && remoteUserData.syncData === null) {
// No remote data and No lasty sync date, so update is not needed
return false;
}
return lastSyncUserData?.ref !== remoteUserData.ref;
}

protected abstract readonly version: number;
protected abstract generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean, userDataSyncConfiguration: IUserDataSyncConfiguration, token: CancellationToken): Promise<IResourcePreview[]>;
protected abstract getMergeResult(resourcePreview: IResourcePreview, token: CancellationToken): Promise<IMergeResult>;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/extensionsSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
this.logService.info(`${this.syncResourceLogLabel}: Updated remote extensions.${remote.added.length ? ` Added: ${JSON.stringify(remote.added.map(e => e.identifier.id))}.` : ''}${remote.updated.length ? ` Updated: ${JSON.stringify(remote.updated.map(e => e.identifier.id))}.` : ''}${remote.removed.length ? ` Removed: ${JSON.stringify(remote.removed.map(e => e.identifier.id))}.` : ''}`);
}

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
// update last sync
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized extensions...`);
await this.updateLastSyncUserData(remoteUserData, { skippedExtensions });
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/globalStateSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
this.logService.info(`${this.syncResourceLogLabel}: Updated remote ui state`);
}

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
// update last sync
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized ui state...`);
await this.updateLastSyncUserData(remoteUserData);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/keybindingsSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser implem
await this.fileService.del(this.previewResource);
} catch (e) { /* ignore */ }

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized keybindings...`);
await this.updateLastSyncUserData(remoteUserData, { platformSpecific: this.syncKeybindingsPerPlatform() });
this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized keybindings`);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/settingsSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class SettingsSynchroniser extends AbstractJsonFileSynchroniser implement
await this.fileService.del(this.previewResource);
} catch (e) { /* ignore */ }

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized settings...`);
await this.updateLastSyncUserData(remoteUserData);
this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized settings`);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/snippetsSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class SnippetsSynchroniser extends AbstractSynchroniser implements IUserD
remoteUserData = await this.updateRemoteSnippets(accptedResourcePreviews, remoteUserData, force);
}

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
// update last sync
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized snippets...`);
await this.updateLastSyncUserData(remoteUserData);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/tasksSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class TasksSynchroniser extends AbstractFileSynchroniser implements IUser
await this.fileService.del(this.previewResource);
} catch (e) { /* ignore */ }

if (lastSyncUserData?.ref !== remoteUserData.ref) {
if (this.hasToUpdateLastSyncUserData(remoteUserData, lastSyncUserData)) {
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized tasks...`);
await this.updateLastSyncUserData(remoteUserData);
this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized tasks`);
Expand Down

0 comments on commit ee0c8c4

Please sign in to comment.