mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 1ec43773e37997841c5af42b33ddb180e9735bf2
This commit is contained in:
@@ -395,6 +395,8 @@ export function toFileOperationResult(error: Error): FileOperationResult {
|
||||
return FileOperationResult.FILE_NOT_FOUND;
|
||||
case FileSystemProviderErrorCode.FileIsADirectory:
|
||||
return FileOperationResult.FILE_IS_DIRECTORY;
|
||||
case FileSystemProviderErrorCode.FileNotADirectory:
|
||||
return FileOperationResult.FILE_NOT_DIRECTORY;
|
||||
case FileSystemProviderErrorCode.NoPermissions:
|
||||
return FileOperationResult.FILE_PERMISSION_DENIED;
|
||||
case FileSystemProviderErrorCode.FileExists:
|
||||
@@ -763,6 +765,7 @@ export const enum FileOperationResult {
|
||||
FILE_TOO_LARGE,
|
||||
FILE_INVALID_PATH,
|
||||
FILE_EXCEEDS_MEMORY_LIMIT,
|
||||
FILE_NOT_DIRECTORY,
|
||||
FILE_OTHER_ERROR
|
||||
}
|
||||
|
||||
|
||||
@@ -668,6 +668,9 @@ export class DiskFileSystemProvider extends Disposable implements
|
||||
case 'EISDIR':
|
||||
code = FileSystemProviderErrorCode.FileIsADirectory;
|
||||
break;
|
||||
case 'ENOTDIR':
|
||||
code = FileSystemProviderErrorCode.FileNotADirectory;
|
||||
break;
|
||||
case 'EEXIST':
|
||||
code = FileSystemProviderErrorCode.FileExists;
|
||||
break;
|
||||
|
||||
@@ -1409,6 +1409,24 @@ suite('Disk File Service', function () {
|
||||
assert.equal(error!.fileOperationResult, FileOperationResult.FILE_IS_DIRECTORY);
|
||||
});
|
||||
|
||||
test('readFile - FILE_NOT_DIRECTORY', async () => {
|
||||
if (isWindows) {
|
||||
return; // error code does not seem to be supported on windows
|
||||
}
|
||||
|
||||
const resource = URI.file(join(testDir, 'lorem.txt', 'file.txt'));
|
||||
|
||||
let error: FileOperationError | undefined = undefined;
|
||||
try {
|
||||
await service.readFile(resource);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
assert.ok(error);
|
||||
assert.equal(error!.fileOperationResult, FileOperationResult.FILE_NOT_DIRECTORY);
|
||||
});
|
||||
|
||||
test('readFile - FILE_NOT_FOUND', async () => {
|
||||
const resource = URI.file(join(testDir, '404.html'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user