mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -170,12 +170,12 @@ export function parseStorage(storage: IStorage): IParsedStorage {
|
||||
};
|
||||
}
|
||||
|
||||
export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWorkspaceId: IWorkspaceIdentifier, storage: IStorage): void {
|
||||
export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWorkspace: IWorkspaceIdentifier, storage: IStorage): string {
|
||||
const parsed = parseStorage(storage);
|
||||
|
||||
const newStorageKey = URI.from({ path: toWorkspaceId.id, scheme: 'root' }).toString();
|
||||
const newWorkspaceId = URI.from({ path: toWorkspace.id, scheme: 'root' }).toString();
|
||||
|
||||
// Find in which location the workspace storage is to be migrated rom
|
||||
// Find in which location the workspace storage is to be migrated from
|
||||
let storageForWorkspace: StorageObject;
|
||||
if (parsed.multiRoot.has(fromWorkspaceId)) {
|
||||
storageForWorkspace = parsed.multiRoot.get(fromWorkspaceId);
|
||||
@@ -192,7 +192,9 @@ export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWo
|
||||
return; // make sure to never migrate the workspace identifier
|
||||
}
|
||||
|
||||
storage.setItem(`${StorageService.WORKSPACE_PREFIX}${newStorageKey}/${key}`, storageForWorkspace[key]);
|
||||
storage.setItem(`${StorageService.WORKSPACE_PREFIX}${newWorkspaceId}/${key}`, storageForWorkspace[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return newWorkspaceId;
|
||||
}
|
||||
@@ -33,16 +33,27 @@ export class StorageService implements IStorageService {
|
||||
private _globalStorage: IStorage;
|
||||
|
||||
private workspaceKey: string;
|
||||
private _workspaceId: string;
|
||||
|
||||
constructor(
|
||||
globalStorage: IStorage,
|
||||
workspaceStorage: IStorage,
|
||||
private workspaceId?: string,
|
||||
workspaceId?: string,
|
||||
legacyWorkspaceId?: number
|
||||
) {
|
||||
this._globalStorage = globalStorage;
|
||||
this._workspaceStorage = workspaceStorage || globalStorage;
|
||||
|
||||
this.setWorkspaceId(workspaceId, legacyWorkspaceId);
|
||||
}
|
||||
|
||||
public get workspaceId(): string {
|
||||
return this._workspaceId;
|
||||
}
|
||||
|
||||
public setWorkspaceId(workspaceId: string, legacyWorkspaceId?: number): void {
|
||||
this._workspaceId = workspaceId;
|
||||
|
||||
// Calculate workspace storage key
|
||||
this.workspaceKey = this.getWorkspaceKey(workspaceId);
|
||||
|
||||
@@ -53,10 +64,6 @@ export class StorageService implements IStorageService {
|
||||
}
|
||||
}
|
||||
|
||||
public get storageId(): string {
|
||||
return this.workspaceId;
|
||||
}
|
||||
|
||||
public get globalStorage(): IStorage {
|
||||
return this._globalStorage;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,25 @@ import { StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
suite('Storage Migration', () => {
|
||||
let storage = window.localStorage;
|
||||
//slet storage = window.localStorage;
|
||||
|
||||
setup(() => {
|
||||
//storage.clear();
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
//storage.clear();
|
||||
});
|
||||
|
||||
test('Parse Storage (Global)', () => {
|
||||
assert.equal(1, 1);
|
||||
// const service = createService();
|
||||
|
||||
// const parsed = parseStorage(storage);
|
||||
|
||||
// assert.equal(parsed.global.size, 4);
|
||||
// assert.equal(parsed.global.get('key1'), service.get('key1'));
|
||||
// assert.equal(parsed.global.get('key2.something'), service.get('key2.something'));
|
||||
// assert.equal(parsed.global.get('key3/special'), service.get('key3/special'));
|
||||
// assert.equal(parsed.global.get('key4 space'), service.get('key4 space'));
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@
|
||||
import * as assert from 'assert';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspaceContextService, IWorkspace, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
|
||||
@@ -19,9 +19,7 @@ suite('Workbench StorageSevice', () => {
|
||||
setup(() => {
|
||||
instantiationService = new TestInstantiationService();
|
||||
contextService = instantiationService.stub(IWorkspaceContextService, <IWorkspaceContextService>{
|
||||
hasWorkspace: () => {
|
||||
return true;
|
||||
},
|
||||
getWorkbenchState: () => WorkbenchState.FOLDER,
|
||||
getWorkspace: () => {
|
||||
return <IWorkspace>TestWorkspace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user