Merge from vscode b8c2e7108b3cae7aa2782112da654bedd8bb3a52 (#4808)

This commit is contained in:
Karl Burtram
2019-04-02 14:35:06 -07:00
committed by GitHub
parent e83a6f9c2e
commit f8706abebe
53 changed files with 495 additions and 584 deletions

View File

@@ -318,14 +318,14 @@ export class BulkEdit {
if (edit.newUri && edit.oldUri) {
// rename
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.existsFile(edit.newUri)) {
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.exists(edit.newUri)) {
continue; // not overwriting, but ignoring, and the target file exists
}
await this._textFileService.move(edit.oldUri, edit.newUri, options.overwrite);
} else if (!edit.newUri && edit.oldUri) {
// delete file
if (await this._fileService.existsFile(edit.oldUri)) {
if (await this._fileService.exists(edit.oldUri)) {
let useTrash = this._configurationService.getValue<boolean>('files.enableTrash');
if (useTrash && !(await this._fileService.hasCapability(edit.oldUri, FileSystemProviderCapabilities.Trash))) {
useTrash = false; // not supported by provider
@@ -336,7 +336,7 @@ export class BulkEdit {
}
} else if (edit.newUri && !edit.oldUri) {
// create file
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.existsFile(edit.newUri)) {
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.exists(edit.newUri)) {
continue; // not overwriting, but ignoring, and the target file exists
}
await this._textFileService.create(edit.newUri, undefined, { overwrite: options.overwrite });

View File

@@ -373,7 +373,7 @@ export class ConfigurationEditingService {
}
private async resolveModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const exists = await this.fileService.existsFile(resource);
const exists = await this.fileService.exists(resource);
if (!exists) {
await this.fileService.updateContent(resource, '{}', { encoding: 'utf8' });
}

View File

@@ -84,7 +84,7 @@ export class JSONEditingService implements IJSONEditingService {
}
private async resolveModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const exists = await this.fileService.existsFile(resource);
const exists = await this.fileService.exists(resource);
if (!exists) {
await this.fileService.updateContent(resource, '{}', { encoding: 'utf8' });
}

View File

@@ -369,13 +369,13 @@ class FileServiceBasedWorkspaceConfiguration extends AbstractWorkspaceConfigurat
private watchWorkspaceConfigurationFile(): void {
if (this.workspaceConfig) {
this.fileService.watchFileChanges(this.workspaceConfig);
this.fileService.watch(this.workspaceConfig);
}
}
private unWatchWorkspaceConfigurtionFile(): void {
if (this.workspaceConfig) {
this.fileService.unwatchFileChanges(this.workspaceConfig);
this.fileService.unwatch(this.workspaceConfig);
}
}
@@ -638,7 +638,7 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
private doLoadFolderConfigurationContents(): Promise<Array<{ resource: URI, value: string }>> {
const workspaceFilePathToConfiguration: { [relativeWorkspacePath: string]: Promise<IContent | undefined> } = Object.create(null);
const bulkContentFetchromise = Promise.resolve(this.fileService.resolveFile(this.folderConfigurationPath))
const bulkContentFetchromise = Promise.resolve(this.fileService.resolve(this.folderConfigurationPath))
.then(stat => {
if (stat.isDirectory && stat.children) {
stat.children

View File

@@ -87,7 +87,7 @@ export class RemoteFileDialog {
return this.pickResource().then(async fileFolderUri => {
if (fileFolderUri) {
const stat = await this.fileService.resolveFile(fileFolderUri);
const stat = await this.fileService.resolve(fileFolderUri);
return <IURIToOpen[]>[{ uri: fileFolderUri, typeHint: stat.isDirectory ? 'folder' : 'file' }];
}
@@ -98,7 +98,7 @@ export class RemoteFileDialog {
public async showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined> {
this.scheme = this.getScheme(options.defaultUri, options.availableFileSystems);
this.requiresTrailing = true;
const newOptions = await this.getOptions(options);
const newOptions = await this.getOptions(options, true);
if (!newOptions) {
return Promise.resolve(undefined);
}
@@ -114,15 +114,19 @@ export class RemoteFileDialog {
});
}
private async getOptions(options: ISaveDialogOptions | IOpenDialogOptions): Promise<IOpenDialogOptions | undefined> {
private async getOptions(options: ISaveDialogOptions | IOpenDialogOptions, isSave: boolean = false): Promise<IOpenDialogOptions | undefined> {
let defaultUri = options.defaultUri;
if (!defaultUri) {
const filename = (defaultUri && isSave && (resources.dirname(defaultUri).path === '/')) ? resources.basename(defaultUri) : undefined;
if (!defaultUri || filename) {
const env = await this.remoteAgentService.getEnvironment();
if (env) {
defaultUri = env.userHome;
} else {
defaultUri = URI.from({ scheme: this.scheme, path: this.environmentService.userHome });
}
if (filename) {
defaultUri = resources.joinPath(defaultUri, filename);
}
}
if ((this.scheme !== Schemas.file) && !this.fileService.canHandleResource(defaultUri)) {
this.notificationService.info(nls.localize('remoteFileDialog.notConnectedToRemote', 'File system provider for {0} is not available.', defaultUri.toString()));
@@ -159,7 +163,7 @@ export class RemoteFileDialog {
let ext: string = resources.extname(homedir);
if (this.options.defaultUri) {
try {
stat = await this.fileService.resolveFile(this.options.defaultUri);
stat = await this.fileService.resolve(this.options.defaultUri);
} catch (e) {
// The file or folder doesn't exist
}
@@ -292,8 +296,8 @@ export class RemoteFileDialog {
let stat: IFileStat | undefined;
let statDirname: IFileStat | undefined;
try {
statDirname = await this.fileService.resolveFile(inputUriDirname);
stat = await this.fileService.resolveFile(inputUri);
statDirname = await this.fileService.resolve(inputUriDirname);
stat = await this.fileService.resolve(inputUri);
} catch (e) {
// do nothing
}
@@ -335,7 +339,7 @@ export class RemoteFileDialog {
if (this.endsWithSlash(value) || (!resources.isEqual(this.currentFolder, resources.dirname(valueUri), true) && resources.isEqualOrParent(this.currentFolder, resources.dirname(valueUri), true))) {
let stat: IFileStat | undefined;
try {
stat = await this.fileService.resolveFile(valueUri);
stat = await this.fileService.resolve(valueUri);
} catch (e) {
// do nothing
}
@@ -346,7 +350,7 @@ export class RemoteFileDialog {
if (!resources.isEqual(this.currentFolder, inputUriDirname, true)) {
let statWithoutTrailing: IFileStat | undefined;
try {
statWithoutTrailing = await this.fileService.resolveFile(inputUriDirname);
statWithoutTrailing = await this.fileService.resolve(inputUriDirname);
} catch (e) {
// do nothing
}
@@ -387,8 +391,8 @@ export class RemoteFileDialog {
let stat: IFileStat | undefined;
let statDirname: IFileStat | undefined;
try {
statDirname = await this.fileService.resolveFile(resources.dirname(uri));
stat = await this.fileService.resolveFile(uri);
statDirname = await this.fileService.resolve(resources.dirname(uri));
stat = await this.fileService.resolve(uri);
} catch (e) {
// do nothing
}
@@ -509,7 +513,7 @@ export class RemoteFileDialog {
const backDir = this.createBackItem(currentFolder);
try {
const folder = await this.fileService.resolveFile(currentFolder);
const folder = await this.fileService.resolve(currentFolder);
const fileNames = folder.children ? folder.children.map(child => child.name) : [];
const items = await Promise.all(fileNames.map(fileName => this.createItem(fileName, currentFolder)));
for (let item of items) {
@@ -558,7 +562,7 @@ export class RemoteFileDialog {
private async createItem(filename: string, parent: URI): Promise<FileQuickPickItem | undefined> {
let fullPath = resources.joinPath(parent, filename);
try {
const stat = await this.fileService.resolveFile(fullPath);
const stat = await this.fileService.resolve(fullPath);
if (stat.isDirectory) {
filename = this.basenameWithTrailingSlash(fullPath);
return { label: filename, uri: fullPath, isFolder: true, iconClasses: getIconClasses(this.modelService, this.modeService, fullPath || undefined, FileKind.FOLDER) };

View File

@@ -280,7 +280,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return Promise.reject(error);
};
const statsPromise = this.resolveFile(resource).then(stat => {
const statsPromise = this.resolve(resource).then(stat => {
result.resource = stat.resource;
result.name = stat.name;
result.mtime = stat.mtime;
@@ -812,11 +812,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
));
}
moveFile(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
move(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
return this.moveOrCopyFile(source, target, false, !!overwrite);
}
copyFile(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
copy(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
return this.moveOrCopyFile(source, target, true, !!overwrite);
}
@@ -828,7 +828,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return this.doMoveOrCopyFile(sourcePath, targetPath, keepCopy, overwrite).then(() => {
// 2.) resolve
return this.resolve(target, { resolveMetadata: true }).then(result => {
return this.doResolve(target, { resolveMetadata: true }).then(result => {
// Events (unless it was a no-op because paths are identical)
if (sourcePath !== targetPath) {
@@ -952,9 +952,9 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return paths.normalize(resource.fsPath);
}
private resolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
private resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
private resolve(resource: uri, options: IResolveFileOptions = Object.create(null)): Promise<IFileStat> {
private doResolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
private doResolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
private doResolve(resource: uri, options: IResolveFileOptions = Object.create(null)): Promise<IFileStat> {
return this.toStatResolver(resource).then(model => model.resolve(options));
}
@@ -966,7 +966,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
watchFileChanges(resource: uri): void {
watch(resource: uri): void {
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource for watching: ${resource}`);
// Check for existing watcher first
@@ -1000,11 +1000,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Wait a bit and try to install watcher again, assuming that the file was renamed quickly ("Atomic Save")
setTimeout(() => {
this.existsFile(resource).then(exists => {
this.exists(resource).then(exists => {
// File still exists, so reapply the watcher
if (exists) {
this.watchFileChanges(resource);
this.watch(resource);
}
// File seems to be really gone, so emit a deleted event
@@ -1063,7 +1063,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
unwatchFileChanges(resource: uri): void {
unwatch(resource: uri): void {
const watcher = this.activeFileChangesWatchers.get(resource);
if (watcher && --watcher.count === 0) {
watcher.unwatch();
@@ -1092,14 +1092,14 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Tests only
resolveFile(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
resolveFile(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: uri, options?: IResolveFileOptions): Promise<IFileStat> {
return this.resolve(resource, options);
resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat> {
return this.doResolve(resource, options);
}
resolveFiles(toResolve: { resource: uri, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOptions => this.resolve(resourceAndOptions.resource, resourceAndOptions.options)
resolveAll(toResolve: { resource: uri, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOptions => this.doResolve(resourceAndOptions.resource, resourceAndOptions.options)
.then(stat => ({ stat, success: true }), error => ({ stat: undefined, success: false }))));
}
@@ -1110,7 +1110,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return pfs.mkdirp(absolutePath).then(() => {
// 2.) Resolve
return this.resolve(resource, { resolveMetadata: true }).then(result => {
return this.doResolve(resource, { resolveMetadata: true }).then(result => {
// Events
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, result));
@@ -1120,8 +1120,8 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
existsFile(resource: uri): Promise<boolean> {
return this.resolveFile(resource).then(() => true, () => false);
exists(resource: uri): Promise<boolean> {
return this.resolve(resource).then(() => true, () => false);
}
}

View File

@@ -140,18 +140,18 @@ class WorkspaceWatchLogic extends Disposable {
}
}
this._watches.set(resource.toString(), resource);
this._fileService.watchFileChanges(resource, { recursive: true, excludes });
this._fileService.watch(resource, { recursive: true, excludes });
}
private _unwatchWorkspace(resource: URI) {
if (this._watches.has(resource.toString())) {
this._fileService.unwatchFileChanges(resource);
this._fileService.unwatch(resource);
this._watches.delete(resource.toString());
}
}
private _unwatchWorkspaces() {
this._watches.forEach(uri => this._fileService.unwatchFileChanges(uri));
this._watches.forEach(uri => this._fileService.unwatch(uri));
this._watches.clear();
}
}
@@ -223,11 +223,11 @@ export class RemoteFileService extends FileService {
});
}
resolveFile(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
resolve(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
if (resource.scheme === Schemas.file) {
return super.resolveFile(resource, options);
return super.resolve(resource, options);
} else {
return this._doResolveFiles([{ resource, options }]).then(data => {
if (data.length !== 1 || !data[0].success) {
@@ -279,7 +279,7 @@ export class RemoteFileService extends FileService {
private _readFile(resource: URI, options: IResolveContentOptions = Object.create(null)): Promise<IStreamContent> {
return this._withProvider(resource).then(provider => {
return this.resolveFile(resource).then(fileStat => {
return this.resolve(resource).then(fileStat => {
if (fileStat.isDirectory) {
// todo@joh cannot copy a folder
@@ -409,7 +409,7 @@ export class RemoteFileService extends FileService {
target.once('error', err => reject(err));
target.once('finish', (_: unknown) => resolve(undefined));
}).then(_ => {
return this.resolveFile(resource, { resolveMetadata: true }) as Promise<IFileStatWithMetadata>;
return this.resolve(resource, { resolveMetadata: true }) as Promise<IFileStatWithMetadata>;
});
}
@@ -433,9 +433,9 @@ export class RemoteFileService extends FileService {
private _activeWatches = new Map<string, { unwatch: Promise<IDisposable>, count: number }>();
watchFileChanges(resource: URI, opts: IWatchOptions = { recursive: false, excludes: [] }): void {
watch(resource: URI, opts: IWatchOptions = { recursive: false, excludes: [] }): void {
if (resource.scheme === Schemas.file) {
return super.watchFileChanges(resource);
return super.watch(resource);
}
const key = resource.toString();
@@ -455,9 +455,9 @@ export class RemoteFileService extends FileService {
});
}
unwatchFileChanges(resource: URI): void {
unwatch(resource: URI): void {
if (resource.scheme === Schemas.file) {
return super.unwatchFileChanges(resource);
return super.unwatch(resource);
}
let entry = this._activeWatches.get(resource.toString());
if (entry && --entry.count === 0) {

View File

@@ -348,15 +348,15 @@ suite('FileService', () => {
});
});
test('watchFileChanges', function (done) {
test('watch', function (done) {
const toWatch = uri.file(path.join(testDir, 'index.html'));
service.watchFileChanges(toWatch);
service.watch(toWatch);
service.onFileChanges((e: FileChangesEvent) => {
assert.ok(e);
service.unwatchFileChanges(toWatch);
service.unwatch(toWatch);
done();
});
@@ -365,15 +365,15 @@ suite('FileService', () => {
}, 100);
});
// test('watchFileChanges - support atomic save', function (done) {
// test('watch - support atomic save', function (done) {
// const toWatch = uri.file(path.join(testDir, 'index.html'));
// service.watchFileChanges(toWatch);
// service.watch(toWatch);
// service.onFileChanges((e: FileChangesEvent) => {
// assert.ok(e);
// service.unwatchFileChanges(toWatch);
// service.unwatch(toWatch);
// done();
// });

View File

@@ -152,9 +152,9 @@ export class FileService2 extends Disposable implements IFileService {
//#region File Metadata Resolving
async resolveFile(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
async resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
async resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
async resolve(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
async resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
async resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
try {
return await this.doResolveFile(resource, options);
} catch (error) {
@@ -251,9 +251,9 @@ export class FileService2 extends Disposable implements IFileService {
return Promise.resolve(fileStat);
}
async resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
async resolveFiles(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResultWithMetadata[]>;
async resolveFiles(toResolve: { resource: URI; options?: IResolveFileOptions; }[]): Promise<IResolveFileResult[]> {
async resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
async resolveAll(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResultWithMetadata[]>;
async resolveAll(toResolve: { resource: URI; options?: IResolveFileOptions; }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(async entry => {
try {
return { stat: await this.doResolveFile(entry.resource, entry.options), success: true };
@@ -265,9 +265,9 @@ export class FileService2 extends Disposable implements IFileService {
}));
}
async existsFile(resource: URI): Promise<boolean> {
async exists(resource: URI): Promise<boolean> {
try {
return !!(await this.resolveFile(resource));
return !!(await this.resolve(resource));
} catch (error) {
return false;
}
@@ -295,7 +295,7 @@ export class FileService2 extends Disposable implements IFileService {
// validate overwrite
const overwrite = !!(options && options.overwrite);
if (await this.existsFile(resource)) {
if (await this.exists(resource)) {
if (!overwrite) {
throw new FileOperationError(localize('fileExists', "File to create already exists ({0})", resource.toString(true)), FileOperationResult.FILE_MODIFIED_SINCE, options);
}
@@ -328,7 +328,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// events
const fileStat = await this.resolveFile(resource, { resolveMetadata: true });
const fileStat = await this.resolve(resource, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
@@ -350,7 +350,7 @@ export class FileService2 extends Disposable implements IFileService {
//#region Move/Copy/Delete/Create Folder
async moveFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
async move(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
const sourceProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(source));
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(target));
@@ -358,13 +358,13 @@ export class FileService2 extends Disposable implements IFileService {
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', overwrite);
// resolve and send events
const fileStat = await this.resolveFile(target, { resolveMetadata: true });
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'move' ? FileOperation.MOVE : FileOperation.COPY, fileStat));
return fileStat;
}
async copyFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
async copy(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
const sourceProvider = await this.withProvider(source);
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(target));
@@ -372,7 +372,7 @@ export class FileService2 extends Disposable implements IFileService {
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', overwrite);
// resolve and send events
const fileStat = await this.resolveFile(target, { resolveMetadata: true });
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'copy' ? FileOperation.COPY : FileOperation.MOVE, fileStat));
return fileStat;
@@ -409,7 +409,7 @@ export class FileService2 extends Disposable implements IFileService {
// when copying via buffer/unbuffered, we have to manually
// traverse the source if it is a folder and not a file
const sourceFile = await this.resolveFile(source);
const sourceFile = await this.resolve(source);
if (sourceFile.isDirectory) {
return this.doCopyFolder(sourceProvider, sourceFile, targetProvider, target, overwrite).then(() => mode);
} else {
@@ -467,7 +467,7 @@ export class FileService2 extends Disposable implements IFileService {
await Promise.all(sourceFolder.children.map(async sourceChild => {
const targetChild = joinPath(targetFolder, sourceChild.name);
if (sourceChild.isDirectory) {
return this.doCopyFolder(sourceProvider, await this.resolveFile(sourceChild.resource), targetProvider, targetChild, overwrite);
return this.doCopyFolder(sourceProvider, await this.resolve(sourceChild.resource), targetProvider, targetChild, overwrite);
} else {
return this.doCopyFile(sourceProvider, sourceChild.resource, targetProvider, targetChild, overwrite);
}
@@ -489,7 +489,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// Extra checks if target exists and this is not a rename
const exists = await this.existsFile(target);
const exists = await this.exists(target);
if (exists && !isCaseChange) {
// Bail out if target exists and we are not about to overwrite
@@ -514,7 +514,7 @@ export class FileService2 extends Disposable implements IFileService {
await this.mkdirp(provider, resource);
// events
const fileStat = await this.resolveFile(resource, { resolveMetadata: true });
const fileStat = await this.resolve(resource, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
@@ -565,8 +565,8 @@ export class FileService2 extends Disposable implements IFileService {
// Validate recursive
const recursive = !!(options && options.recursive);
if (!recursive && await this.existsFile(resource)) {
const stat = await this.resolveFile(resource);
if (!recursive && await this.exists(resource)) {
const stat = await this.resolve(resource);
if (stat.isDirectory && Array.isArray(stat.children) && stat.children.length > 0) {
throw new Error(localize('deleteFailed', "Failed to delete non-empty folder '{0}'.", resource.toString()));
}
@@ -586,12 +586,12 @@ export class FileService2 extends Disposable implements IFileService {
private _onFileChanges: Emitter<FileChangesEvent> = this._register(new Emitter<FileChangesEvent>());
get onFileChanges(): Event<FileChangesEvent> { return this._onFileChanges.event; }
watchFileChanges(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.watchFileChanges(resource));
watch(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.watch(resource));
}
unwatchFileChanges(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.unwatchFileChanges(resource));
unwatch(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.unwatch(resource));
}
//#endregion
@@ -690,7 +690,7 @@ export class FileService2 extends Disposable implements IFileService {
private async doPipeBufferedToUnbuffered(sourceProvider: IFileSystemProviderWithOpenReadWriteCloseCapability, source: URI, targetProvider: IFileSystemProviderWithFileReadWriteCapability, target: URI, overwrite: boolean): Promise<void> {
// Determine file size
const size = (await this.resolveFile(source, { resolveMetadata: true })).size;
const size = (await this.resolve(source, { resolveMetadata: true })).size;
// Open handle
const sourceHandle = await sourceProvider.open(source, { create: false });

View File

@@ -225,10 +225,6 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
await this.doDelete(filePath, opts);
} catch (error) {
if (error.code === 'ENOENT') {
return Promise.resolve(); // tolerate that the file might not exist
}
throw this.toFileSystemProviderError(error);
}
}

View File

@@ -100,7 +100,7 @@ suite('Disk File Service', () => {
let event: FileOperationEvent | undefined;
disposables.push(service.onAfterOperation(e => event = e));
const parent = await service.resolveFile(URI.file(testDir));
const parent = await service.resolve(URI.file(testDir));
const newFolderResource = URI.file(join(parent.resource.fsPath, 'newFolder'));
@@ -121,7 +121,7 @@ suite('Disk File Service', () => {
disposables.push(service.onAfterOperation(e => event = e));
const multiFolderPaths = ['a', 'couple', 'of', 'folders'];
const parent = await service.resolveFile(URI.file(testDir));
const parent = await service.resolve(URI.file(testDir));
const newFolderResource = URI.file(join(parent.resource.fsPath, ...multiFolderPaths));
@@ -138,26 +138,26 @@ suite('Disk File Service', () => {
assert.equal(event!.target!.isDirectory, true);
});
test('existsFile', async () => {
let exists = await service.existsFile(URI.file(testDir));
test('exists', async () => {
let exists = await service.exists(URI.file(testDir));
assert.equal(exists, true);
exists = await service.existsFile(URI.file(testDir + 'something'));
exists = await service.exists(URI.file(testDir + 'something'));
assert.equal(exists, false);
});
test('resolveFile', async () => {
const resolved = await service.resolveFile(URI.file(testDir), { resolveTo: [URI.file(join(testDir, 'deep'))] });
test('resolve', async () => {
const resolved = await service.resolve(URI.file(testDir), { resolveTo: [URI.file(join(testDir, 'deep'))] });
assert.equal(resolved.children!.length, 8);
const deep = (getByName(resolved, 'deep')!);
assert.equal(deep.children!.length, 4);
});
test('resolveFile - directory', async () => {
test('resolve - directory', async () => {
const testsElements = ['examples', 'other', 'index.html', 'site.css'];
const result = await service.resolveFile(URI.file(getPathFromAmdModule(require, './fixtures/resolver')));
const result = await service.resolve(URI.file(getPathFromAmdModule(require, './fixtures/resolver')));
assert.ok(result);
assert.ok(result.children);
@@ -187,10 +187,10 @@ suite('Disk File Service', () => {
});
});
test('resolveFile - directory - with metadata', async () => {
test('resolve - directory - with metadata', async () => {
const testsElements = ['examples', 'other', 'index.html', 'site.css'];
const result = await service.resolveFile(URI.file(getPathFromAmdModule(require, './fixtures/resolver')), { resolveMetadata: true });
const result = await service.resolve(URI.file(getPathFromAmdModule(require, './fixtures/resolver')), { resolveMetadata: true });
assert.ok(result);
assert.ok(result.children);
@@ -222,9 +222,9 @@ suite('Disk File Service', () => {
});
});
test('resolveFile - directory - resolveTo single directory', async () => {
test('resolve - directory - resolveTo single directory', async () => {
const resolverFixturesPath = getPathFromAmdModule(require, './fixtures/resolver');
const result = await service.resolveFile(URI.file(resolverFixturesPath), { resolveTo: [URI.file(join(resolverFixturesPath, 'other/deep'))] });
const result = await service.resolve(URI.file(resolverFixturesPath), { resolveTo: [URI.file(join(resolverFixturesPath, 'other/deep'))] });
assert.ok(result);
assert.ok(result.children);
@@ -246,7 +246,7 @@ suite('Disk File Service', () => {
test('resolve directory - resolveTo multiple directories', async () => {
const resolverFixturesPath = getPathFromAmdModule(require, './fixtures/resolver');
const result = await service.resolveFile(URI.file(resolverFixturesPath), {
const result = await service.resolve(URI.file(resolverFixturesPath), {
resolveTo: [
URI.file(join(resolverFixturesPath, 'other/deep')),
URI.file(join(resolverFixturesPath, 'examples'))
@@ -278,7 +278,7 @@ suite('Disk File Service', () => {
test('resolve directory - resolveSingleChildFolders', async () => {
const resolverFixturesPath = getPathFromAmdModule(require, './fixtures/resolver/other');
const result = await service.resolveFile(URI.file(resolverFixturesPath), { resolveSingleChildDescendants: true });
const result = await service.resolve(URI.file(resolverFixturesPath), { resolveSingleChildDescendants: true });
assert.ok(result);
assert.ok(result.children);
@@ -294,8 +294,8 @@ suite('Disk File Service', () => {
assert.equal(deep!.children!.length, 4);
});
test('resolveFiles', async () => {
const res = await service.resolveFiles([
test('resolves', async () => {
const res = await service.resolveAll([
{ resource: URI.file(testDir), options: { resolveTo: [URI.file(join(testDir, 'deep'))] } },
{ resource: URI.file(join(testDir, 'deep')) }
]);
@@ -311,7 +311,7 @@ suite('Disk File Service', () => {
assert.equal(r2.name, 'deep');
});
test('resolveFile - folder symbolic link', async () => {
test('resolve - folder symbolic link', async () => {
if (isWindows) {
return; // not happy
}
@@ -319,13 +319,13 @@ suite('Disk File Service', () => {
const link = URI.file(join(testDir, 'deep-link'));
await symlink(join(testDir, 'deep'), link.fsPath);
const resolved = await service.resolveFile(link);
const resolved = await service.resolve(link);
assert.equal(resolved.children!.length, 4);
assert.equal(resolved.isDirectory, true);
assert.equal(resolved.isSymbolicLink, true);
});
test('resolveFile - file symbolic link', async () => {
test('resolve - file symbolic link', async () => {
if (isWindows) {
return; // not happy
}
@@ -333,12 +333,12 @@ suite('Disk File Service', () => {
const link = URI.file(join(testDir, 'lorem.txt-linked'));
await symlink(join(testDir, 'lorem.txt'), link.fsPath);
const resolved = await service.resolveFile(link);
const resolved = await service.resolve(link);
assert.equal(resolved.isDirectory, false);
assert.equal(resolved.isSymbolicLink, true);
});
test('resolveFile - invalid symbolic link does not break', async () => {
test('resolve - invalid symbolic link does not break', async () => {
if (isWindows) {
return; // not happy
}
@@ -346,7 +346,7 @@ suite('Disk File Service', () => {
const link = URI.file(join(testDir, 'foo'));
await symlink(link.fsPath, join(testDir, 'bar'));
const resolved = await service.resolveFile(URI.file(testDir));
const resolved = await service.resolve(URI.file(testDir));
assert.equal(resolved.isDirectory, true);
assert.equal(resolved.children!.length, 8);
});
@@ -356,7 +356,7 @@ suite('Disk File Service', () => {
disposables.push(service.onAfterOperation(e => event = e));
const resource = URI.file(join(testDir, 'deep', 'conway.js'));
const source = await service.resolveFile(resource);
const source = await service.resolve(resource);
await service.del(source.resource);
@@ -371,7 +371,7 @@ suite('Disk File Service', () => {
disposables.push(service.onAfterOperation(e => event = e));
const resource = URI.file(join(testDir, 'deep'));
const source = await service.resolveFile(resource);
const source = await service.resolve(resource);
await service.del(source.resource, { recursive: true });
@@ -383,7 +383,7 @@ suite('Disk File Service', () => {
test('deleteFolder (non recursive)', async () => {
const resource = URI.file(join(testDir, 'deep'));
const source = await service.resolveFile(resource);
const source = await service.resolve(resource);
try {
await service.del(source.resource);
@@ -394,7 +394,7 @@ suite('Disk File Service', () => {
}
});
test('moveFile', async () => {
test('move', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
@@ -403,7 +403,7 @@ suite('Disk File Service', () => {
const target = URI.file(join(dirname(source.fsPath), 'other.html'));
const renamed = await service.moveFile(source, target);
const renamed = await service.move(source, target);
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(existsSync(source.fsPath), false);
@@ -418,56 +418,56 @@ suite('Disk File Service', () => {
assert.equal(sourceContents.toString(), targetContents.toString());
});
test('moveFile - across providers (buffered => buffered)', async () => {
test('move - across providers (buffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await testMoveAcrossProviders();
});
test('moveFile - across providers (unbuffered => unbuffered)', async () => {
test('move - across providers (unbuffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveAcrossProviders();
});
test('moveFile - across providers (buffered => unbuffered)', async () => {
test('move - across providers (buffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveAcrossProviders();
});
test('moveFile - across providers (unbuffered => buffered)', async () => {
test('move - across providers (unbuffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await testMoveAcrossProviders();
});
test('moveFile - across providers - large (buffered => buffered)', async () => {
test('move - across providers - large (buffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await testMoveAcrossProviders('lorem.txt');
});
test('moveFile - across providers - large (unbuffered => unbuffered)', async () => {
test('move - across providers - large (unbuffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveAcrossProviders('lorem.txt');
});
test('moveFile - across providers - large (buffered => unbuffered)', async () => {
test('move - across providers - large (buffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveAcrossProviders('lorem.txt');
});
test('moveFile - across providers - large (unbuffered => buffered)', async () => {
test('move - across providers - large (unbuffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
@@ -483,7 +483,7 @@ suite('Disk File Service', () => {
const target = URI.file(join(dirname(source.fsPath), 'other.html')).with({ scheme: testSchema });
const renamed = await service.moveFile(source, target);
const renamed = await service.move(source, target);
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(existsSync(source.fsPath), false);
@@ -498,7 +498,7 @@ suite('Disk File Service', () => {
assert.equal(sourceContents.toString(), targetContents.toString());
}
test('moveFile - multi folder', async () => {
test('move - multi folder', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
@@ -507,7 +507,7 @@ suite('Disk File Service', () => {
const source = URI.file(join(testDir, 'index.html'));
const renamed = await service.moveFile(source, URI.file(join(dirname(source.fsPath), renameToPath)));
const renamed = await service.move(source, URI.file(join(dirname(source.fsPath), renameToPath)));
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(existsSync(source.fsPath), false);
@@ -517,13 +517,13 @@ suite('Disk File Service', () => {
assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath);
});
test('moveFile - directory', async () => {
test('move - directory', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
const source = URI.file(join(testDir, 'deep'));
const renamed = await service.moveFile(source, URI.file(join(dirname(source.fsPath), 'deeper')));
const renamed = await service.move(source, URI.file(join(dirname(source.fsPath), 'deeper')));
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(existsSync(source.fsPath), false);
@@ -533,28 +533,28 @@ suite('Disk File Service', () => {
assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath);
});
test('moveFile - directory - across providers (buffered => buffered)', async () => {
test('move - directory - across providers (buffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await testMoveFolderAcrossProviders();
});
test('moveFile - directory - across providers (unbuffered => unbuffered)', async () => {
test('move - directory - across providers (unbuffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveFolderAcrossProviders();
});
test('moveFile - directory - across providers (buffered => unbuffered)', async () => {
test('move - directory - across providers (buffered => unbuffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileReadWrite);
await testMoveFolderAcrossProviders();
});
test('moveFile - directory - across providers (unbuffered => buffered)', async () => {
test('move - directory - across providers (unbuffered => buffered)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
setCapabilities(testProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
@@ -570,7 +570,7 @@ suite('Disk File Service', () => {
const target = URI.file(join(dirname(source.fsPath), 'deeper')).with({ scheme: testSchema });
const renamed = await service.moveFile(source, target);
const renamed = await service.move(source, target);
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(existsSync(source.fsPath), false);
@@ -586,14 +586,14 @@ suite('Disk File Service', () => {
}
}
test('moveFile - MIX CASE', async () => {
test('move - MIX CASE', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
const source = URI.file(join(testDir, 'index.html'));
await service.resolveFile(source);
await service.resolve(source);
const renamed = await service.moveFile(source, URI.file(join(dirname(source.fsPath), 'INDEX.html')));
const renamed = await service.move(source, URI.file(join(dirname(source.fsPath), 'INDEX.html')));
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.equal(basename(renamed.resource.fsPath), 'INDEX.html');
@@ -603,33 +603,33 @@ suite('Disk File Service', () => {
assert.equal(event!.target!.resource.fsPath, renamed.resource.fsPath);
});
test('moveFile - source parent of target', async () => {
test('move - source parent of target', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
await service.resolveFile(URI.file(join(testDir, 'index.html')));
await service.resolve(URI.file(join(testDir, 'index.html')));
try {
await service.moveFile(URI.file(testDir), URI.file(join(testDir, 'binary.txt')));
await service.move(URI.file(testDir), URI.file(join(testDir, 'binary.txt')));
} catch (e) {
assert.ok(e);
assert.ok(!event!);
}
});
test('moveFile - FILE_MOVE_CONFLICT', async () => {
test('move - FILE_MOVE_CONFLICT', async () => {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
const source = await service.resolveFile(URI.file(join(testDir, 'index.html')));
const source = await service.resolve(URI.file(join(testDir, 'index.html')));
try {
await service.moveFile(source.resource, URI.file(join(testDir, 'binary.txt')));
await service.move(source.resource, URI.file(join(testDir, 'binary.txt')));
} catch (e) {
assert.equal(e.fileOperationResult, FileOperationResult.FILE_MOVE_CONFLICT);
assert.ok(!event!);
}
});
test('moveFile - overwrite folder with file', async () => {
test('move - overwrite folder with file', async () => {
let createEvent: FileOperationEvent;
let moveEvent: FileOperationEvent;
let deleteEvent: FileOperationEvent;
@@ -643,12 +643,12 @@ suite('Disk File Service', () => {
}
}));
const parent = await service.resolveFile(URI.file(testDir));
const parent = await service.resolve(URI.file(testDir));
const folderResource = URI.file(join(parent.resource.fsPath, 'conway.js'));
const f = await service.createFolder(folderResource);
const source = URI.file(join(testDir, 'deep', 'conway.js'));
const moved = await service.moveFile(source, f.resource, true);
const moved = await service.move(source, f.resource, true);
assert.equal(existsSync(moved.resource.fsPath), true);
assert.ok(statSync(moved.resource.fsPath).isFile);
@@ -660,32 +660,32 @@ suite('Disk File Service', () => {
assert.equal(deleteEvent!.resource.fsPath, folderResource.fsPath);
});
test('copyFile', async () => {
await doTestCopyFile();
test('copy', async () => {
await doTestCopy();
});
test('copyFile - unbuffered (FileSystemProviderCapabilities.FileReadWrite)', async () => {
test('copy - unbuffered (FileSystemProviderCapabilities.FileReadWrite)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
await doTestCopyFile();
await doTestCopy();
});
test('copyFile - unbuffered large (FileSystemProviderCapabilities.FileReadWrite)', async () => {
test('copy - unbuffered large (FileSystemProviderCapabilities.FileReadWrite)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileReadWrite);
await doTestCopyFile('lorem.txt');
await doTestCopy('lorem.txt');
});
test('copyFile - buffered (FileSystemProviderCapabilities.FileOpenReadWriteClose)', async () => {
test('copy - buffered (FileSystemProviderCapabilities.FileOpenReadWriteClose)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await doTestCopyFile();
await doTestCopy();
});
test('copyFile - buffered large (FileSystemProviderCapabilities.FileOpenReadWriteClose)', async () => {
test('copy - buffered large (FileSystemProviderCapabilities.FileOpenReadWriteClose)', async () => {
setCapabilities(fileProvider, FileSystemProviderCapabilities.FileOpenReadWriteClose);
await doTestCopyFile('lorem.txt');
await doTestCopy('lorem.txt');
});
function setCapabilities(provider: TestDiskFileSystemProvider, capabilities: FileSystemProviderCapabilities): void {
@@ -695,14 +695,14 @@ suite('Disk File Service', () => {
}
}
async function doTestCopyFile(sourceName: string = 'index.html') {
async function doTestCopy(sourceName: string = 'index.html') {
let event: FileOperationEvent;
disposables.push(service.onAfterOperation(e => event = e));
const source = await service.resolveFile(URI.file(join(testDir, sourceName)));
const source = await service.resolve(URI.file(join(testDir, sourceName)));
const target = URI.file(join(testDir, 'other.html'));
const copied = await service.copyFile(source.resource, target);
const copied = await service.copy(source.resource, target);
assert.equal(existsSync(copied.resource.fsPath), true);
assert.equal(existsSync(source.resource.fsPath), true);
@@ -718,7 +718,7 @@ suite('Disk File Service', () => {
assert.equal(sourceContents.toString(), targetContents.toString());
}
test('copyFile - overwrite folder with file', async () => {
test('copy - overwrite folder with file', async () => {
let createEvent: FileOperationEvent;
let copyEvent: FileOperationEvent;
let deleteEvent: FileOperationEvent;
@@ -732,12 +732,12 @@ suite('Disk File Service', () => {
}
}));
const parent = await service.resolveFile(URI.file(testDir));
const parent = await service.resolve(URI.file(testDir));
const folderResource = URI.file(join(parent.resource.fsPath, 'conway.js'));
const f = await service.createFolder(folderResource);
const source = URI.file(join(testDir, 'deep', 'conway.js'));
const copied = await service.copyFile(source, f.resource, true);
const copied = await service.copy(source, f.resource, true);
assert.equal(existsSync(copied.resource.fsPath), true);
assert.ok(statSync(copied.resource.fsPath).isFile);
@@ -749,28 +749,28 @@ suite('Disk File Service', () => {
assert.equal(deleteEvent!.resource.fsPath, folderResource.fsPath);
});
test('copyFile - MIX CASE', async () => {
const source = await service.resolveFile(URI.file(join(testDir, 'index.html')));
const renamed = await service.moveFile(source.resource, URI.file(join(dirname(source.resource.fsPath), 'CONWAY.js')));
test('copy - MIX CASE', async () => {
const source = await service.resolve(URI.file(join(testDir, 'index.html')));
const renamed = await service.move(source.resource, URI.file(join(dirname(source.resource.fsPath), 'CONWAY.js')));
assert.equal(existsSync(renamed.resource.fsPath), true);
assert.ok(readdirSync(testDir).some(f => f === 'CONWAY.js'));
const source_1 = await service.resolveFile(URI.file(join(testDir, 'deep', 'conway.js')));
const source_1 = await service.resolve(URI.file(join(testDir, 'deep', 'conway.js')));
const targetParent = URI.file(testDir);
const target = targetParent.with({ path: posix.join(targetParent.path, posix.basename(source_1.resource.path)) });
const res = await service.copyFile(source_1.resource, target, true);
const res = await service.copy(source_1.resource, target, true);
assert.equal(existsSync(res.resource.fsPath), true);
assert.ok(readdirSync(testDir).some(f => f === 'conway.js'));
});
test('copyFile - same file should throw', async () => {
const source = await service.resolveFile(URI.file(join(testDir, 'index.html')));
test('copy - same file should throw', async () => {
const source = await service.resolve(URI.file(join(testDir, 'index.html')));
const targetParent = URI.file(dirname(source.resource.fsPath));
const target = targetParent.with({ path: posix.join(targetParent.path, posix.basename(source.resource.path)) });
try {
await service.copyFile(source.resource, target, true);
await service.copy(source.resource, target, true);
} catch (error) {
assert.ok(error);
}

View File

@@ -208,7 +208,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
return this.fileService.existsFile(this.resource)
return this.fileService.exists(this.resource)
.then(exists => {
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
const result: Promise<any> = exists ? Promise.resolve(null) : this.fileService.updateContent(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });

View File

@@ -160,7 +160,7 @@ class OutputFileListener extends Disposable {
}
private doWatch(): Promise<void> {
return this.fileService.resolveFile(this.file, { resolveMetadata: true })
return this.fileService.resolve(this.file, { resolveMetadata: true })
.then(stat => {
if (stat.etag !== this.etag) {
this.etag = stat.etag;

View File

@@ -161,7 +161,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return true;
}
return this.fileService.existsFile(this.resource).then(exists => !exists);
return this.fileService.exists(this.resource).then(exists => !exists);
});
} else {
checkOrphanedPromise = Promise.resolve(false);

View File

@@ -718,7 +718,7 @@ export class TextFileService extends Disposable implements ITextFileService {
}
// Otherwise we can only copy
return this.fileService.copyFile(resource, target).then(() => true);
return this.fileService.copy(resource, target).then(() => true);
}).then(result => {
// Return early if the operation was not running
@@ -748,7 +748,7 @@ export class TextFileService extends Disposable implements ITextFileService {
// Otherwise create the target file empty if it does not exist already and resolve it from there
else {
targetModelResolver = this.fileService.existsFile(target).then<any>(exists => {
targetModelResolver = this.fileService.exists(target).then<any>(exists => {
targetExists = exists;
// create target model adhoc if file does not exist yet
@@ -964,7 +964,7 @@ export class TextFileService extends Disposable implements ITextFileService {
return this.revertAll(dirtySourceModels.map(dirtySourceModel => dirtySourceModel.getResource()), { soft: true }).then(() => {
// Rename to target
return this.fileService.moveFile(source, target, overwrite).then(() => {
return this.fileService.move(source, target, overwrite).then(() => {
// Load models that were dirty before
return Promise.all(dirtyTargetModels.map(dirtyTargetModel => this.models.loadOrCreate(dirtyTargetModel))).then(() => undefined);

View File

@@ -396,12 +396,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (this.fileService && !resources.isEqual(newTheme.location, this.watchedColorThemeLocation)) {
if (this.watchedColorThemeLocation) {
this.fileService.unwatchFileChanges(this.watchedColorThemeLocation);
this.fileService.unwatch(this.watchedColorThemeLocation);
this.watchedColorThemeLocation = undefined;
}
if (newTheme.location && (newTheme.watch || !!this.environmentService.extensionDevelopmentLocationURI)) {
this.watchedColorThemeLocation = newTheme.location;
this.fileService.watchFileChanges(this.watchedColorThemeLocation);
this.fileService.watch(this.watchedColorThemeLocation);
}
}
@@ -514,12 +514,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (this.fileService && !resources.isEqual(iconThemeData.location, this.watchedIconThemeLocation)) {
if (this.watchedIconThemeLocation) {
this.fileService.unwatchFileChanges(this.watchedIconThemeLocation);
this.fileService.unwatch(this.watchedIconThemeLocation);
this.watchedIconThemeLocation = undefined;
}
if (iconThemeData.location && (iconThemeData.watch || !!this.environmentService.extensionDevelopmentLocationURI)) {
this.watchedIconThemeLocation = iconThemeData.location;
this.fileService.watchFileChanges(this.watchedIconThemeLocation);
this.fileService.watch(this.watchedIconThemeLocation);
}
}