mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd (#5074)
* Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd * fix tests
This commit is contained in:
@@ -5,13 +5,10 @@
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IResolveContentOptions, ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
|
||||
|
||||
export const IBackupFileService = createDecorator<IBackupFileService>('backupFileService');
|
||||
|
||||
export const BACKUP_FILE_RESOLVE_OPTIONS: IResolveContentOptions = { acceptTextOnly: true, encoding: 'utf8' };
|
||||
|
||||
/**
|
||||
* A service that handles any I/O and state associated with the backup system.
|
||||
*/
|
||||
|
||||
@@ -8,15 +8,17 @@ import * as crypto from 'crypto';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { URI as Uri } from 'vs/base/common/uri';
|
||||
import { ResourceQueue } from 'vs/base/common/async';
|
||||
import { IBackupFileService, BACKUP_FILE_RESOLVE_OPTIONS } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IFileService, ITextSnapshot, TextSnapshotReadable } from 'vs/platform/files/common/files';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { readToMatchingString } from 'vs/base/node/stream';
|
||||
import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { createTextBufferFactoryFromStream, createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { TextSnapshotReadable } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
|
||||
export interface IBackupFilesModel {
|
||||
resolve(backupRoot: string): Promise<IBackupFilesModel>;
|
||||
@@ -249,19 +251,21 @@ class BackupFileServiceImpl implements IBackupFileService {
|
||||
}
|
||||
|
||||
resolveBackupContent(backup: Uri): Promise<ITextBufferFactory> {
|
||||
return this.fileService.resolveStreamContent(backup, BACKUP_FILE_RESOLVE_OPTIONS).then(content => {
|
||||
return this.fileService.readFileStream(backup).then(content => {
|
||||
|
||||
// Add a filter method to filter out everything until the meta marker
|
||||
let metaFound = false;
|
||||
const metaPreambleFilter = (chunk: string) => {
|
||||
const metaPreambleFilter = (chunk: VSBuffer) => {
|
||||
const chunkString = chunk.toString();
|
||||
|
||||
if (!metaFound && chunk) {
|
||||
const metaIndex = chunk.indexOf(BackupFileServiceImpl.META_MARKER);
|
||||
const metaIndex = chunkString.indexOf(BackupFileServiceImpl.META_MARKER);
|
||||
if (metaIndex === -1) {
|
||||
return ''; // meta not yet found, return empty string
|
||||
return VSBuffer.fromString(''); // meta not yet found, return empty string
|
||||
}
|
||||
|
||||
metaFound = true;
|
||||
return chunk.substr(metaIndex + 1); // meta found, return everything after
|
||||
return VSBuffer.fromString(chunkString.substr(metaIndex + 1)); // meta found, return everything after
|
||||
}
|
||||
|
||||
return chunk;
|
||||
|
||||
@@ -12,20 +12,17 @@ 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 { LegacyFileService } from 'vs/workbench/services/files/node/fileService';
|
||||
import { TextModel, createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { TestContextService, TestTextResourceConfigurationService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { getRandomTestPath } from 'vs/base/test/node/testUtils';
|
||||
import { Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
|
||||
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 { FileService } from 'vs/workbench/services/files/common/fileService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { DiskFileSystemProvider } from 'vs/workbench/services/files2/node/diskFileSystemProvider';
|
||||
import { DiskFileSystemProvider } from 'vs/workbench/services/files/node/diskFileSystemProvider';
|
||||
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
|
||||
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice');
|
||||
const backupHome = path.join(parentDir, 'Backups');
|
||||
@@ -58,14 +55,8 @@ class TestBackupEnvironmentService extends WorkbenchEnvironmentService {
|
||||
|
||||
class TestBackupFileService extends BackupFileService {
|
||||
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
|
||||
const fileService = new FileService2(new NullLogService());
|
||||
const fileService = new FileService(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 environmentService = new TestBackupEnvironmentService(workspaceBackupPath);
|
||||
|
||||
super(environmentService, fileService);
|
||||
|
||||
Reference in New Issue
Block a user