From 951cce5f9a13a2bd341d6483a009e9151529104b Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 2 Dec 2024 23:31:28 -0500 Subject: [PATCH 1/2] Fix SSH sample ext to work with FileSystemProvider Signed-off-by: Timothy Johnson --- .../uss-profile-sample/src/SshUssApi.ts | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) 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(); } From 8df7b9a4443710383f14d07112d5ef6c7e33d965 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 6 Jan 2025 12:17:40 -0500 Subject: [PATCH 2/2] Fix parsing of Unix file permissions Signed-off-by: Timothy Johnson --- vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts b/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts index 0f18ebd..4049fc6 100644 --- a/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts +++ b/vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts @@ -34,9 +34,10 @@ export class SshUssApi implements MainframeInteraction.IUss { const response = []; if ((await client.stat(ussFilePath)).isDirectory) { for (const fileInfo of await client.list(ussFilePath)) { + const permString = Object.values(fileInfo.rights).reduce((all, perm) => all.concat(perm), fileInfo.type); response.push({ name: fileInfo.name, - mode: fileInfo.type + fileInfo.owner + fileInfo.group + fileInfo.rights.other, + mode: permString, size: fileInfo.size, uid: fileInfo.owner, gid: fileInfo.group, @@ -72,7 +73,7 @@ export class SshUssApi implements MainframeInteraction.IUss { }); } - public async putContent(inputFilePath: string, ussFilePath: string): Promise { + public async putContent(inputFilePath: string, ussFilePath: string, _options?: zosfiles.IUploadOptions): Promise { return this.withClient(this.getSession(), async (client) => { const response = await client.fastPut(inputFilePath, ussFilePath); return this.buildZosFilesResponse(response);