From 89c38d35541092b55ef4753977920e9aa6ffc7cd Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 9 Feb 2021 10:36:39 -0600 Subject: [PATCH] Update storage promise A new doStore was added. --- .../src/vs/platform/storage/browser/storageService.ts | 7 +------ lib/vscode/src/vs/platform/storage/common/storage.ts | 8 ++------ .../src/vs/platform/storage/node/storageService.ts | 7 +------ lib/vscode/src/vs/server/browser/client.ts | 10 +++++----- .../src/vs/workbench/api/browser/mainThreadStorage.ts | 6 +----- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/lib/vscode/src/vs/platform/storage/browser/storageService.ts b/lib/vscode/src/vs/platform/storage/browser/storageService.ts index 97249914..489a8582 100644 --- a/lib/vscode/src/vs/platform/storage/browser/storageService.ts +++ b/lib/vscode/src/vs/platform/storage/browser/storageService.ts @@ -118,13 +118,8 @@ export class BrowserStorageService extends AbstractStorageService { return this.getStorage(scope).getNumber(key, fallbackValue); } -<<<<<<< HEAD - store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise { + protected doStore(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise { return this.getStorage(scope).set(key, value); -======= - protected doStore(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void { - this.getStorage(scope).set(key, value); ->>>>>>> e4a830e9b7ca039c7c70697786d29f5b6679d775 } protected doRemove(key: string, scope: StorageScope): void { diff --git a/lib/vscode/src/vs/platform/storage/common/storage.ts b/lib/vscode/src/vs/platform/storage/common/storage.ts index 09c4bd42..a15f1c2f 100644 --- a/lib/vscode/src/vs/platform/storage/common/storage.ts +++ b/lib/vscode/src/vs/platform/storage/common/storage.ts @@ -104,11 +104,7 @@ export interface IStorageService { * @param target allows to define the target of the storage operation * to either the current machine or user. */ -<<<<<<< HEAD - store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise | void; -======= - store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope, target: StorageTarget): void; ->>>>>>> e4a830e9b7ca039c7c70697786d29f5b6679d775 + store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope, target: StorageTarget): Promise | void; /** * Delete an element stored under the provided key from storage. @@ -402,7 +398,7 @@ export abstract class AbstractStorageService extends Disposable implements IStor abstract getNumber(key: string, scope: StorageScope, fallbackValue: number): number; abstract getNumber(key: string, scope: StorageScope, fallbackValue?: number): number | undefined; - protected abstract doStore(key: string, value: string | boolean | number, scope: StorageScope): void; + protected abstract doStore(key: string, value: string | boolean | number, scope: StorageScope): Promise | void; protected abstract doRemove(key: string, scope: StorageScope): void; diff --git a/lib/vscode/src/vs/platform/storage/node/storageService.ts b/lib/vscode/src/vs/platform/storage/node/storageService.ts index 759374dd..6352d193 100644 --- a/lib/vscode/src/vs/platform/storage/node/storageService.ts +++ b/lib/vscode/src/vs/platform/storage/node/storageService.ts @@ -188,13 +188,8 @@ export class NativeStorageService extends AbstractStorageService { return this.getStorage(scope).getNumber(key, fallbackValue); } -<<<<<<< HEAD - store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise { + protected doStore(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise { return this.getStorage(scope).set(key, value); -======= - protected doStore(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void { - this.getStorage(scope).set(key, value); ->>>>>>> e4a830e9b7ca039c7c70697786d29f5b6679d775 } protected doRemove(key: string, scope: StorageScope): void { diff --git a/lib/vscode/src/vs/server/browser/client.ts b/lib/vscode/src/vs/server/browser/client.ts index 685030c3..c4180112 100644 --- a/lib/vscode/src/vs/server/browser/client.ts +++ b/lib/vscode/src/vs/server/browser/client.ts @@ -1,23 +1,23 @@ import { Emitter } from 'vs/base/common/event'; +import * as path from 'vs/base/common/path'; import { URI } from 'vs/base/common/uri'; import { localize } from 'vs/nls'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ILocalizationsService } from 'vs/platform/localizations/common/localizations'; +import { ILogService } from 'vs/platform/log/common/log'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { Registry } from 'vs/platform/registry/common/platform'; import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection'; +import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { INodeProxyService, NodeProxyChannelClient } from 'vs/server/common/nodeProxy'; import { TelemetryChannelClient } from 'vs/server/common/telemetry'; +import { Options } from 'vs/server/ipc.d'; import 'vs/workbench/contrib/localizations/browser/localizations.contribution'; import { LocalizationsService } from 'vs/workbench/services/localizations/electron-browser/localizationsService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; -import { Options } from 'vs/server/ipc.d'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; -import { ILogService } from 'vs/platform/log/common/log'; -import * as path from 'vs/base/common/path'; class TelemetryService extends TelemetryChannelClient { public constructor( @@ -179,7 +179,7 @@ export const initialize = async (services: ServiceCollection): Promise => } } - storageService.store('csLastUpdateNotification', Date.now(), StorageScope.GLOBAL); + storageService.store('csLastUpdateNotification', Date.now(), StorageScope.GLOBAL, StorageTarget.MACHINE); (services.get(INotificationService) as INotificationService).notify({ severity: Severity.Info, message: `[code-server v${json.latest}](https://github.com/cdr/code-server/releases/tag/v${json.latest}) has been released!`, diff --git a/lib/vscode/src/vs/workbench/api/browser/mainThreadStorage.ts b/lib/vscode/src/vs/workbench/api/browser/mainThreadStorage.ts index 5bf707b6..0206ff96 100644 --- a/lib/vscode/src/vs/workbench/api/browser/mainThreadStorage.ts +++ b/lib/vscode/src/vs/workbench/api/browser/mainThreadStorage.ts @@ -66,12 +66,8 @@ export class MainThreadStorage implements MainThreadStorageShape { let jsonValue: string; try { jsonValue = JSON.stringify(value); -<<<<<<< HEAD - await this._storageService.store(key, jsonValue, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE); -======= // Extension state is synced separately through extensions - this._storageService.store(key, jsonValue, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE); ->>>>>>> e4a830e9b7ca039c7c70697786d29f5b6679d775 + await this._storageService.store(key, jsonValue, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE); } catch (err) { return Promise.reject(err); }