Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSH sample ext to work with FileSystemProvider #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions vscode-extension-samples/uss-profile-sample/src/SshUssApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ export class SshUssApi implements MainframeInteraction.IUss {
public async fileList(ussFilePath: string): Promise<zosfiles.IZosFilesResponse> {
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 });
});
Expand All @@ -50,12 +52,16 @@ export class SshUssApi implements MainframeInteraction.IUss {
return Promise.resolve(false);
}

public async getContents(ussFilePath: string, options: zosfiles.IDownloadOptions): Promise<zosfiles.IZosFilesResponse> {
public async getContents(ussFilePath: string, options: zosfiles.IDownloadSingleOptions): Promise<zosfiles.IZosFilesResponse> {
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 });
});
}

Expand Down Expand Up @@ -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<T>(err);
} finally {
await client.end();
}
Expand Down
Loading