提交 c7837ea7 编写于 作者: B Benjamin Pasero

remove legacy workspace migration code

上级 e191f750
......@@ -176,11 +176,6 @@ export class WindowsManager implements IWindowsMainService {
state.folderPath = state.workspacePath;
state.workspacePath = void 0;
}
// TODO@Ben migration to new workspace ID
if (state.workspace) {
state.workspace.id = this.workspacesService.getWorkspaceId(state.workspace.configPath);
}
});
}
......@@ -277,7 +272,6 @@ export class WindowsManager implements IWindowsMainService {
private onBeforeQuit(): void {
const currentWindowsState: ILegacyWindowsState = {
openedWindows: [],
openedFolders: [], // TODO@Ben migration so that old clients do not fail over data (prevents NPEs)
lastPluginDevelopmentHostWindow: this.windowsState.lastPluginDevelopmentHostWindow,
lastActiveWindow: this.lastClosedWindowState
};
......
......@@ -225,22 +225,6 @@ export class BackupMainService implements IBackupMainService {
const hasBackups = this.hasBackupsSync(backupPath);
const missingWorkspace = hasBackups && !fs.existsSync(workspacePath);
// TODO@Ben migration from old workspace ID to new
if (hasBackups && !missingWorkspace && !isSingleFolderWorkspaceIdentifier(workspaceId) && workspaceId.id !== this.workspacesService.getWorkspaceId(workspacePath)) {
staleBackupWorkspaces.push({ workspaceIdentifier: workspaceId, backupPath, target: workspaceOrFolder.target });
const identifier = { id: this.workspacesService.getWorkspaceId(workspacePath), configPath: workspacePath } as IWorkspaceIdentifier;
this.pushBackupPathsSync(identifier, this.backups.rootWorkspaces);
const newWorkspaceBackupPath = path.join(this.backupHome, identifier.id);
try {
fs.renameSync(backupPath, newWorkspaceBackupPath);
} catch (ex) {
this.logService.error(`Backup: Could not rename backup folder for legacy workspace: ${ex.toString()}`);
this.removeBackupPathSync(identifier, this.backups.rootWorkspaces);
}
}
// If the workspace/folder has no backups, make sure to delete it
// If the workspace/folder has backups, but the target workspace is missing, convert backups to empty ones
if (!hasBackups || missingWorkspace) {
......
......@@ -19,15 +19,8 @@ import { ILogService } from 'vs/platform/log/common/log';
import { isEqual, isEqualOrParent } from 'vs/base/common/paths';
import { coalesce } from 'vs/base/common/arrays';
import { createHash } from 'crypto';
import URI from 'vs/base/common/uri';
import * as json from 'vs/base/common/json';
// TODO@Ben migration
export interface ILegacyStoredWorkspace {
id: string;
folders: string[];
}
export class WorkspacesMainService implements IWorkspacesMainService {
public _serviceBrand: any;
......@@ -108,13 +101,6 @@ export class WorkspacesMainService implements IWorkspacesMainService {
throw new Error(`${path} cannot be parsed as JSON file (${error}).`);
}
// TODO@Ben migration
const legacyStoredWorkspace = (<any>storedWorkspace) as ILegacyStoredWorkspace;
if (legacyStoredWorkspace.folders.some(folder => typeof folder === 'string')) {
storedWorkspace.folders = legacyStoredWorkspace.folders.map(folder => ({ path: URI.parse(folder).fsPath }));
writeFileSync(path, JSON.stringify(storedWorkspace, null, '\t'));
}
// Filter out folders which do not have a path set
if (Array.isArray(storedWorkspace.folders)) {
storedWorkspace.folders = storedWorkspace.folders.filter(folder => !!folder.path);
......
......@@ -20,7 +20,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { EmptyWorkspaceServiceImpl, WorkspaceServiceImpl, WorkspaceService } from 'vs/workbench/services/configuration/node/configuration';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { realpath, readFile, writeFile } from 'vs/base/node/pfs';
import { realpath } from 'vs/base/node/pfs';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import path = require('path');
import gracefulFs = require('graceful-fs');
......@@ -42,7 +42,6 @@ import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspace
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
import { CredentialsChannelClient } from 'vs/platform/credentials/node/credentialsIpc';
import { migrateStorageToMultiRootWorkspace } from 'vs/platform/storage/common/migration';
import fs = require('fs');
gracefulFs.gracefulify(fs); // enable gracefulFs
......@@ -112,7 +111,6 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
}
function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService, workspacesService: IWorkspacesService): TPromise<WorkspaceService> {
return migrateWorkspaceId(configuration).then(() => {
return validateWorkspacePath(configuration).then(() => {
let workspaceService: WorkspaceServiceImpl | EmptyWorkspaceServiceImpl;
if (configuration.workspace || configuration.folderPath) {
......@@ -123,30 +121,6 @@ function createAndInitializeWorkspaceService(configuration: IWindowConfiguration
return workspaceService.initialize().then(() => workspaceService, error => new EmptyWorkspaceServiceImpl(environmentService));
});
});
}
// TODO@Ben migration
function migrateWorkspaceId(configuration: IWindowConfiguration): TPromise<void> {
if (!configuration.workspace || !configuration.workspace.configPath) {
return TPromise.as(null);
}
return readFile(configuration.workspace.configPath).then(data => {
try {
const raw = JSON.parse(data.toString());
if (raw.id) {
const previousWorkspaceId = raw.id;
delete raw.id;
migrateStorageToMultiRootWorkspace(uri.from({ path: previousWorkspaceId, scheme: 'root' }).toString(), configuration.workspace, window.localStorage);
return writeFile(configuration.workspace.configPath, JSON.stringify(raw, null, '\t'));
}
} catch (error) { };
return void 0;
}).then(() => void 0, () => void 0);
}
function validateWorkspacePath(configuration: IWindowConfiguration): TPromise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册