mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI as Uri } from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IResolveContentOptions, IUpdateContentOptions, ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
@@ -30,7 +30,7 @@ export interface IBackupFileService {
|
||||
* @param resource The resource that is backed up.
|
||||
* @return The backup resource if any.
|
||||
*/
|
||||
loadBackupResource(resource: Uri): Promise<Uri | undefined>;
|
||||
loadBackupResource(resource: URI): Promise<URI | undefined>;
|
||||
|
||||
/**
|
||||
* Given a resource, returns the associated backup resource.
|
||||
@@ -38,7 +38,7 @@ export interface IBackupFileService {
|
||||
* @param resource The resource to get the backup resource for.
|
||||
* @return The backup resource.
|
||||
*/
|
||||
toBackupResource(resource: Uri): Uri;
|
||||
toBackupResource(resource: URI): URI;
|
||||
|
||||
/**
|
||||
* Backs up a resource.
|
||||
@@ -47,14 +47,14 @@ export interface IBackupFileService {
|
||||
* @param content The content of the resource as snapshot.
|
||||
* @param versionId The version id of the resource to backup.
|
||||
*/
|
||||
backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): Promise<void>;
|
||||
backupResource(resource: URI, content: ITextSnapshot, versionId?: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Gets a list of file backups for the current workspace.
|
||||
*
|
||||
* @return The list of backups.
|
||||
*/
|
||||
getWorkspaceFileBackups(): Promise<Uri[]>;
|
||||
getWorkspaceFileBackups(): Promise<URI[]>;
|
||||
|
||||
/**
|
||||
* Resolves the backup for the given resource.
|
||||
@@ -62,14 +62,14 @@ export interface IBackupFileService {
|
||||
* @param value The contents from a backup resource as stream.
|
||||
* @return The backup file's backed up content as text buffer factory.
|
||||
*/
|
||||
resolveBackupContent(backup: Uri): Promise<ITextBufferFactory | undefined>;
|
||||
resolveBackupContent(backup: URI): Promise<ITextBufferFactory | undefined>;
|
||||
|
||||
/**
|
||||
* Discards the backup associated with a resource if it exists..
|
||||
*
|
||||
* @param resource The resource whose backup is being discarded discard to back up.
|
||||
*/
|
||||
discardResourceBackup(resource: Uri): Promise<void>;
|
||||
discardResourceBackup(resource: URI): Promise<void>;
|
||||
|
||||
/**
|
||||
* Discards all backups associated with the current workspace and prevents further backups from
|
||||
|
||||
@@ -242,7 +242,7 @@ class BackupFileServiceImpl implements IBackupFileService {
|
||||
const backupResource = this.toBackupResource(resource);
|
||||
|
||||
return this.ioOperationQueues.queueFor(backupResource).queue(() => {
|
||||
return pfs.del(backupResource.fsPath).then(() => model.remove(backupResource));
|
||||
return pfs.rimraf(backupResource.fsPath, pfs.RimRafMode.MOVE).then(() => model.remove(backupResource));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -251,7 +251,7 @@ class BackupFileServiceImpl implements IBackupFileService {
|
||||
this.isShuttingDown = true;
|
||||
|
||||
return this.ready.then(model => {
|
||||
return pfs.del(this.backupWorkspacePath).then(() => model.clear());
|
||||
return pfs.rimraf(this.backupWorkspacePath, pfs.RimRafMode.MOVE).then(() => model.clear());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,18 @@ import * as path from 'vs/base/common/path';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { URI as Uri } from 'vs/base/common/uri';
|
||||
import { BackupFileService, BackupFilesModel, hashPath } from 'vs/workbench/services/backup/node/backupFileService';
|
||||
import { FileService } from 'vs/workbench/services/files/node/fileService';
|
||||
import { LegacyFileService } from 'vs/workbench/services/files/node/fileService';
|
||||
import { TextModel, createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { TestContextService, TestTextResourceConfigurationService, TestLifecycleService, TestEnvironmentService, TestStorageService, TestWindowService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { TestContextService, TestTextResourceConfigurationService, TestEnvironmentService, TestWindowService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { getRandomTestPath } from 'vs/base/test/node/testUtils';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { snapshotToString } from 'vs/platform/files/common/files';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { FileService2 } from 'vs/workbench/services/files2/common/fileService2';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { DiskFileSystemProvider } from 'vs/workbench/services/files2/node/diskFileSystemProvider';
|
||||
|
||||
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice');
|
||||
const backupHome = path.join(parentDir, 'Backups');
|
||||
@@ -55,7 +56,14 @@ class TestBackupWindowService extends TestWindowService {
|
||||
|
||||
class TestBackupFileService extends BackupFileService {
|
||||
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
|
||||
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
|
||||
const fileService = new FileService2(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.setLegacyService(new LegacyFileService(
|
||||
fileService,
|
||||
new TestContextService(new Workspace(workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))),
|
||||
TestEnvironmentService,
|
||||
new TestTextResourceConfigurationService(),
|
||||
));
|
||||
const windowService = new TestBackupWindowService(workspaceBackupPath);
|
||||
|
||||
super(windowService, fileService);
|
||||
@@ -73,7 +81,7 @@ suite('BackupFileService', () => {
|
||||
service = new TestBackupFileService(workspaceResource, backupHome, workspacesJsonPath);
|
||||
|
||||
// Delete any existing backups completely and then re-create it.
|
||||
return pfs.del(backupHome, os.tmpdir()).then(() => {
|
||||
return pfs.rimraf(backupHome, pfs.RimRafMode.MOVE).then(() => {
|
||||
return pfs.mkdirp(backupHome).then(() => {
|
||||
return pfs.writeFile(workspacesJsonPath, '');
|
||||
});
|
||||
@@ -81,7 +89,7 @@ suite('BackupFileService', () => {
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
return pfs.del(backupHome, os.tmpdir());
|
||||
return pfs.rimraf(backupHome, pfs.RimRafMode.MOVE);
|
||||
});
|
||||
|
||||
suite('hashPath', () => {
|
||||
|
||||
Reference in New Issue
Block a user