mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as crypto from 'crypto';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { writeFileAndFlushSync } from 'vs/base/node/extfs';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { IBackupMainService, IBackupWorkspacesFormat, IEmptyWindowBackupInfo } from 'vs/platform/backup/common/backup';
|
||||
import { IBackupMainService, IBackupWorkspacesFormat, IEmptyWindowBackupInfo, IWorkspaceBackupInfo } from 'vs/platform/backup/common/backup';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
|
||||
@@ -17,7 +17,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { isEqual as areResourcesEquals, getComparisonKey, hasToIgnoreCase } from 'vs/base/common/resources';
|
||||
import { isEqual } from 'vs/base/common/paths';
|
||||
import { isEqual } from 'vs/base/common/extpath';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { writeFile, readFile, readdir, exists, del, rename } from 'vs/base/node/pfs';
|
||||
|
||||
@@ -28,7 +28,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
protected backupHome: string;
|
||||
protected workspacesJsonPath: string;
|
||||
|
||||
private rootWorkspaces: IWorkspaceIdentifier[];
|
||||
private rootWorkspaces: IWorkspaceBackupInfo[];
|
||||
private folderWorkspaces: URI[];
|
||||
private emptyWorkspaces: IEmptyWindowBackupInfo[];
|
||||
|
||||
@@ -60,7 +60,17 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
|
||||
// read workspace backups
|
||||
this.rootWorkspaces = await this.validateWorkspaces(backups.rootWorkspaces);
|
||||
let rootWorkspaces: IWorkspaceBackupInfo[] = [];
|
||||
try {
|
||||
if (Array.isArray(backups.rootURIWorkspaces)) {
|
||||
rootWorkspaces = backups.rootURIWorkspaces.map(f => ({ workspace: { id: f.id, configPath: URI.parse(f.configURIPath) }, remoteAuthority: f.remoteAuthority }));
|
||||
} else if (Array.isArray(backups.rootWorkspaces)) {
|
||||
rootWorkspaces = backups.rootWorkspaces.map(f => ({ workspace: { id: f.id, configPath: URI.file(f.configPath) } }));
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore URI parsing exceptions
|
||||
}
|
||||
this.rootWorkspaces = await this.validateWorkspaces(rootWorkspaces);
|
||||
|
||||
// read folder backups
|
||||
let workspaceFolders: URI[] = [];
|
||||
@@ -90,7 +100,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
await this.save();
|
||||
}
|
||||
|
||||
getWorkspaceBackups(): IWorkspaceIdentifier[] {
|
||||
getWorkspaceBackups(): IWorkspaceBackupInfo[] {
|
||||
if (this.isHotExitOnExitAndWindowClose()) {
|
||||
// Only non-folder windows are restored on main process launch when
|
||||
// hot exit is configured as onExitAndWindowClose.
|
||||
@@ -128,13 +138,13 @@ export class BackupMainService implements IBackupMainService {
|
||||
return this.emptyWorkspaces.slice(0); // return a copy
|
||||
}
|
||||
|
||||
registerWorkspaceBackupSync(workspace: IWorkspaceIdentifier, migrateFrom?: string): string {
|
||||
if (!this.rootWorkspaces.some(w => w.id === workspace.id)) {
|
||||
this.rootWorkspaces.push(workspace);
|
||||
registerWorkspaceBackupSync(workspaceInfo: IWorkspaceBackupInfo, migrateFrom?: string): string {
|
||||
if (!this.rootWorkspaces.some(w => workspaceInfo.workspace.id === w.workspace.id)) {
|
||||
this.rootWorkspaces.push(workspaceInfo);
|
||||
this.saveSync();
|
||||
}
|
||||
|
||||
const backupPath = this.getBackupPath(workspace.id);
|
||||
const backupPath = this.getBackupPath(workspaceInfo.workspace.id);
|
||||
|
||||
if (migrateFrom) {
|
||||
this.moveBackupFolderSync(backupPath, migrateFrom);
|
||||
@@ -178,7 +188,8 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
|
||||
unregisterWorkspaceBackupSync(workspace: IWorkspaceIdentifier): void {
|
||||
let index = arrays.firstIndex(this.rootWorkspaces, w => w.id === workspace.id);
|
||||
const id = workspace.id;
|
||||
let index = arrays.firstIndex(this.rootWorkspaces, w => w.workspace.id === id);
|
||||
if (index !== -1) {
|
||||
this.rootWorkspaces.splice(index, 1);
|
||||
this.saveSync();
|
||||
@@ -202,16 +213,14 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
}
|
||||
|
||||
registerEmptyWindowBackupSync(backupInfo: IEmptyWindowBackupInfo): string {
|
||||
let backupFolder = backupInfo.backupFolder;
|
||||
let remoteAuthority = backupInfo.remoteAuthority;
|
||||
registerEmptyWindowBackupSync(backupFolder?: string, remoteAuthority?: string): string {
|
||||
|
||||
// Generate a new folder if this is a new empty workspace
|
||||
if (!backupFolder) {
|
||||
backupFolder = this.getRandomEmptyWindowId();
|
||||
}
|
||||
|
||||
if (!this.emptyWorkspaces.some(w => isEqual(w.backupFolder, backupFolder, !platform.isLinux))) {
|
||||
if (!this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, backupFolder!, !platform.isLinux))) {
|
||||
this.emptyWorkspaces.push({ backupFolder, remoteAuthority });
|
||||
this.saveSync();
|
||||
}
|
||||
@@ -220,7 +229,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
}
|
||||
|
||||
unregisterEmptyWindowBackupSync(backupFolder: string): void {
|
||||
let index = arrays.firstIndex(this.emptyWorkspaces, w => isEqual(w.backupFolder, backupFolder, !platform.isLinux));
|
||||
let index = arrays.firstIndex(this.emptyWorkspaces, w => !!w.backupFolder && isEqual(w.backupFolder, backupFolder, !platform.isLinux));
|
||||
if (index !== -1) {
|
||||
this.emptyWorkspaces.splice(index, 1);
|
||||
this.saveSync();
|
||||
@@ -231,16 +240,17 @@ export class BackupMainService implements IBackupMainService {
|
||||
return path.join(this.backupHome, oldFolderHash);
|
||||
}
|
||||
|
||||
private async validateWorkspaces(rootWorkspaces: IWorkspaceIdentifier[]): Promise<IWorkspaceIdentifier[]> {
|
||||
private async validateWorkspaces(rootWorkspaces: IWorkspaceBackupInfo[]): Promise<IWorkspaceBackupInfo[]> {
|
||||
if (!Array.isArray(rootWorkspaces)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const seenIds: { [id: string]: boolean } = Object.create(null);
|
||||
const result: IWorkspaceIdentifier[] = [];
|
||||
const result: IWorkspaceBackupInfo[] = [];
|
||||
|
||||
// Validate Workspaces
|
||||
for (let workspace of rootWorkspaces) {
|
||||
for (let workspaceInfo of rootWorkspaces) {
|
||||
const workspace = workspaceInfo.workspace;
|
||||
if (!isWorkspaceIdentifier(workspace)) {
|
||||
return []; // wrong format, skip all entries
|
||||
}
|
||||
@@ -253,8 +263,8 @@ export class BackupMainService implements IBackupMainService {
|
||||
|
||||
// If the workspace has no backups, ignore it
|
||||
if (hasBackups) {
|
||||
if (await exists(workspace.configPath)) {
|
||||
result.push(workspace);
|
||||
if (workspace.configPath.scheme !== Schemas.file || await exists(workspace.configPath.fsPath)) {
|
||||
result.push(workspaceInfo);
|
||||
} else {
|
||||
// If the workspace has backups, but the target workspace is missing, convert backups to empty ones
|
||||
await this.convertToEmptyWindowBackup(backupPath);
|
||||
@@ -344,7 +354,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
|
||||
// New empty window backup
|
||||
let newBackupFolder = this.getRandomEmptyWindowId();
|
||||
while (this.emptyWorkspaces.some(w => isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
|
||||
while (this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
|
||||
newBackupFolder = this.getRandomEmptyWindowId();
|
||||
}
|
||||
|
||||
@@ -365,7 +375,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
|
||||
// New empty window backup
|
||||
let newBackupFolder = this.getRandomEmptyWindowId();
|
||||
while (this.emptyWorkspaces.some(w => isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
|
||||
while (this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
|
||||
newBackupFolder = this.getRandomEmptyWindowId();
|
||||
}
|
||||
|
||||
@@ -421,7 +431,7 @@ export class BackupMainService implements IBackupMainService {
|
||||
|
||||
private serializeBackups(): IBackupWorkspacesFormat {
|
||||
return {
|
||||
rootWorkspaces: this.rootWorkspaces,
|
||||
rootURIWorkspaces: this.rootWorkspaces.map(f => ({ id: f.workspace.id, configURIPath: f.workspace.configPath.toString(), remoteAuthority: f.remoteAuthority })),
|
||||
folderURIWorkspaces: this.folderWorkspaces.map(f => f.toString()),
|
||||
emptyWorkspaceInfos: this.emptyWorkspaces,
|
||||
emptyWorkspaces: this.emptyWorkspaces.map(info => info.backupFolder)
|
||||
|
||||
Reference in New Issue
Block a user