mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -15,6 +15,7 @@ import { joinPath } from 'vs/base/common/resources';
|
||||
import { runWhenIdle, RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { serializableToMap, mapToSerializable } from 'vs/base/common/map';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { assertIsDefined, assertAllDefined } from 'vs/base/common/types';
|
||||
|
||||
export class BrowserStorageService extends Disposable implements IStorageService {
|
||||
|
||||
@@ -26,20 +27,20 @@ export class BrowserStorageService extends Disposable implements IStorageService
|
||||
private readonly _onWillSaveState: Emitter<IWillSaveStateEvent> = this._register(new Emitter<IWillSaveStateEvent>());
|
||||
readonly onWillSaveState: Event<IWillSaveStateEvent> = this._onWillSaveState.event;
|
||||
|
||||
private globalStorage: IStorage;
|
||||
private workspaceStorage: IStorage;
|
||||
private globalStorage: IStorage | undefined;
|
||||
private workspaceStorage: IStorage | undefined;
|
||||
|
||||
private globalStorageDatabase: FileStorageDatabase;
|
||||
private workspaceStorageDatabase: FileStorageDatabase;
|
||||
private globalStorageDatabase: FileStorageDatabase | undefined;
|
||||
private workspaceStorageDatabase: FileStorageDatabase | undefined;
|
||||
|
||||
private globalStorageFile: URI;
|
||||
private workspaceStorageFile: URI;
|
||||
private globalStorageFile: URI | undefined;
|
||||
private workspaceStorageFile: URI | undefined;
|
||||
|
||||
private initializePromise: Promise<void>;
|
||||
private initializePromise: Promise<void> | undefined;
|
||||
private periodicSaveScheduler = this._register(new RunOnceScheduler(() => this.collectState(), 5000));
|
||||
|
||||
get hasPendingUpdate(): boolean {
|
||||
return this.globalStorageDatabase.hasPendingUpdate || this.workspaceStorageDatabase.hasPendingUpdate;
|
||||
return (!!this.globalStorageDatabase && this.globalStorageDatabase.hasPendingUpdate) || (!!this.workspaceStorageDatabase && this.workspaceStorageDatabase.hasPendingUpdate);
|
||||
}
|
||||
|
||||
constructor(
|
||||
@@ -137,16 +138,18 @@ export class BrowserStorageService extends Disposable implements IStorageService
|
||||
}
|
||||
|
||||
private getStorage(scope: StorageScope): IStorage {
|
||||
return scope === StorageScope.GLOBAL ? this.globalStorage : this.workspaceStorage;
|
||||
return assertIsDefined(scope === StorageScope.GLOBAL ? this.globalStorage : this.workspaceStorage);
|
||||
}
|
||||
|
||||
async logStorage(): Promise<void> {
|
||||
const [globalStorage, workspaceStorage, globalStorageFile, workspaceStorageFile] = assertAllDefined(this.globalStorage, this.workspaceStorage, this.globalStorageFile, this.workspaceStorageFile);
|
||||
|
||||
const result = await Promise.all([
|
||||
this.globalStorage.items,
|
||||
this.workspaceStorage.items
|
||||
globalStorage.items,
|
||||
workspaceStorage.items
|
||||
]);
|
||||
|
||||
return logStorage(result[0], result[1], this.globalStorageFile.toString(), this.workspaceStorageFile.toString());
|
||||
return logStorage(result[0], result[1], globalStorageFile.toString(), workspaceStorageFile.toString());
|
||||
}
|
||||
|
||||
async migrate(toWorkspace: IWorkspaceInitializationPayload): Promise<void> {
|
||||
|
||||
@@ -29,7 +29,7 @@ interface ISerializableItemsChangeEvent {
|
||||
|
||||
export class GlobalStorageDatabaseChannel extends Disposable implements IServerChannel {
|
||||
|
||||
private static STORAGE_CHANGE_DEBOUNCE_TIME = 100;
|
||||
private static readonly STORAGE_CHANGE_DEBOUNCE_TIME = 100;
|
||||
|
||||
private readonly _onDidChangeItems: Emitter<ISerializableItemsChangeEvent> = this._register(new Emitter<ISerializableItemsChangeEvent>());
|
||||
readonly onDidChangeItems: Event<ISerializableItemsChangeEvent> = this._onDidChangeItems.event;
|
||||
|
||||
@@ -87,7 +87,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private static STORAGE_NAME = 'state.vscdb';
|
||||
private static readonly STORAGE_NAME = 'state.vscdb';
|
||||
|
||||
private readonly _onDidChangeStorage: Emitter<IStorageChangeEvent> = this._register(new Emitter<IStorageChangeEvent>());
|
||||
readonly onDidChangeStorage: Event<IStorageChangeEvent> = this._onDidChangeStorage.event;
|
||||
|
||||
@@ -15,13 +15,14 @@ import { copy, exists, mkdirp, writeFile } from 'vs/base/node/pfs';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWorkspaceInitializationPayload, isWorkspaceIdentifier, isSingleFolderWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { assertIsDefined, assertAllDefined } from 'vs/base/common/types';
|
||||
|
||||
export class NativeStorageService extends Disposable implements IStorageService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private static WORKSPACE_STORAGE_NAME = 'state.vscdb';
|
||||
private static WORKSPACE_META_NAME = 'workspace.json';
|
||||
private static readonly WORKSPACE_STORAGE_NAME = 'state.vscdb';
|
||||
private static readonly WORKSPACE_META_NAME = 'workspace.json';
|
||||
|
||||
private readonly _onDidChangeStorage: Emitter<IWorkspaceStorageChangeEvent> = this._register(new Emitter<IWorkspaceStorageChangeEvent>());
|
||||
readonly onDidChangeStorage: Event<IWorkspaceStorageChangeEvent> = this._onDidChangeStorage.event;
|
||||
@@ -31,11 +32,11 @@ export class NativeStorageService extends Disposable implements IStorageService
|
||||
|
||||
private globalStorage: IStorage;
|
||||
|
||||
private workspaceStoragePath: string;
|
||||
private workspaceStorage: IStorage;
|
||||
private workspaceStorageListener: IDisposable;
|
||||
private workspaceStoragePath: string | undefined;
|
||||
private workspaceStorage: IStorage | undefined;
|
||||
private workspaceStorageListener: IDisposable | undefined;
|
||||
|
||||
private initializePromise: Promise<void>;
|
||||
private initializePromise: Promise<void> | undefined;
|
||||
|
||||
constructor(
|
||||
globalStorageDatabase: IStorageDatabase,
|
||||
@@ -191,22 +192,24 @@ export class NativeStorageService extends Disposable implements IStorageService
|
||||
|
||||
// Do it
|
||||
await Promise.all([
|
||||
this.globalStorage.close(),
|
||||
this.workspaceStorage.close()
|
||||
this.getStorage(StorageScope.GLOBAL).close(),
|
||||
this.getStorage(StorageScope.WORKSPACE).close()
|
||||
]);
|
||||
}
|
||||
|
||||
private getStorage(scope: StorageScope): IStorage {
|
||||
return scope === StorageScope.GLOBAL ? this.globalStorage : this.workspaceStorage;
|
||||
return assertIsDefined(scope === StorageScope.GLOBAL ? this.globalStorage : this.workspaceStorage);
|
||||
}
|
||||
|
||||
async logStorage(): Promise<void> {
|
||||
const [workspaceStorage, workspaceStoragePath] = assertAllDefined(this.workspaceStorage, this.workspaceStoragePath);
|
||||
|
||||
const result = await Promise.all([
|
||||
this.globalStorage.items,
|
||||
this.workspaceStorage.items
|
||||
workspaceStorage.items
|
||||
]);
|
||||
|
||||
logStorage(result[0], result[1], this.environmentService.globalStorageHome, this.workspaceStoragePath);
|
||||
logStorage(result[0], result[1], this.environmentService.globalStorageHome, workspaceStoragePath);
|
||||
}
|
||||
|
||||
async migrate(toWorkspace: IWorkspaceInitializationPayload): Promise<void> {
|
||||
@@ -215,7 +218,7 @@ export class NativeStorageService extends Disposable implements IStorageService
|
||||
}
|
||||
|
||||
// Close workspace DB to be able to copy
|
||||
await this.workspaceStorage.close();
|
||||
await this.getStorage(StorageScope.WORKSPACE).close();
|
||||
|
||||
// Prepare new workspace storage folder
|
||||
const result = await this.prepareWorkspaceStorageFolder(toWorkspace);
|
||||
@@ -223,7 +226,7 @@ export class NativeStorageService extends Disposable implements IStorageService
|
||||
const newWorkspaceStoragePath = join(result.path, NativeStorageService.WORKSPACE_STORAGE_NAME);
|
||||
|
||||
// Copy current storage over to new workspace storage
|
||||
await copy(this.workspaceStoragePath, newWorkspaceStoragePath);
|
||||
await copy(assertIsDefined(this.workspaceStoragePath), newWorkspaceStoragePath);
|
||||
|
||||
// Recreate and init workspace storage
|
||||
return this.createWorkspaceStorage(newWorkspaceStoragePath).init();
|
||||
|
||||
Reference in New Issue
Block a user