diff --git a/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts b/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts index 87ffea0..0f18ebd 100644 --- a/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts +++ b/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts @@ -32,15 +32,17 @@ export class SshUssApi implements MainframeInteraction.IUss { public async fileList(ussFilePath: string): Promise { return this.withClient(this.getSession(), async (client) => { const response = []; - for (const fileInfo of await client.list(ussFilePath)) { - response.push({ - name: fileInfo.name, - mode: fileInfo.type + fileInfo.owner + fileInfo.group + fileInfo.rights.other, - size: fileInfo.size, - uid: fileInfo.owner, - gid: fileInfo.group, - mtime: fileInfo.modifyTime.toString(), - }); + if ((await client.stat(ussFilePath)).isDirectory) { + for (const fileInfo of await client.list(ussFilePath)) { + response.push({ + name: fileInfo.name, + mode: fileInfo.type + fileInfo.owner + fileInfo.group + fileInfo.rights.other, + size: fileInfo.size, + uid: fileInfo.owner, + gid: fileInfo.group, + mtime: fileInfo.modifyTime, + }); + } } return this.buildZosFilesResponse({ items: response }); }); @@ -50,12 +52,16 @@ export class SshUssApi implements MainframeInteraction.IUss { return Promise.resolve(false); } - public async getContents(ussFilePath: string, options: zosfiles.IDownloadOptions): Promise { + public async getContents(ussFilePath: string, options: zosfiles.IDownloadSingleOptions): Promise { return this.withClient(this.getSession(), async (client) => { - const localPath = options.file as string; - imperative.IO.createDirsSyncFromFilePath(localPath); - const response = await client.fastGet(ussFilePath, localPath); - return this.buildZosFilesResponse(response); + if (options.file != null) { + imperative.IO.createDirsSyncFromFilePath(options.file); + await client.fastGet(ussFilePath, options.file); + } else if (options.stream != null) { + options.stream.write(await client.get(ussFilePath)); + options.stream.end(); + } + return this.buildZosFilesResponse({ etag: ussFilePath }); }); } @@ -119,6 +125,9 @@ export class SshUssApi implements MainframeInteraction.IUss { password: session.ISession.password, }); return await callback(client); + } catch (err) { + console.error(err); + return Promise.reject(err); } finally { await client.end(); }