Skip to content

Commit

Permalink
Fix infinite loop when fetching USS resources with stat() (#3321)
Browse files Browse the repository at this point in the history
* remove query when looking up parent

Signed-off-by: Benjamin Santos <[email protected]>

* remove leftover comment

Signed-off-by: Benjamin Santos <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Benjamin Santos <[email protected]>

---------

Signed-off-by: Benjamin Santos <[email protected]>
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
benjamin-t-santos authored and JillieBeanSim committed Nov 15, 2024
1 parent c041372 commit 8903d1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Updated the test for the default credential manager for better compatibility with Cloud-based platforms such as Eclipse Che and Red Hat OpenShift Dev Spaces. [#3297](https://github.com/zowe/zowe-explorer-vscode/pull/3297)
- Fixed issue where users were not prompted to enter credentials if a 401 error was encountered when opening files, data sets or spools in the editor. [#3197](https://github.com/zowe/zowe-explorer-vscode/issues/3197)
- Fixed issue where profile credential updates or token changes were not reflected within the filesystem. [#3289](https://github.com/zowe/zowe-explorer-vscode/issues/3289)
- Fixed issue to update the success message when changing authentication from token to basic through the 'Change Authentication' option.
- Fixed an issue where fetching a USS file using `UssFSProvider.stat()` with a `fetch=true` query would cause Zowe Explorer to get stuck in an infinite loop.

## `3.0.2`

Expand Down
23 changes: 13 additions & 10 deletions packages/zowe-explorer/src/trees/uss/UssFSProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,18 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
public async listFiles(profile: imperative.IProfileLoaded, uri: vscode.Uri, keepRelative: boolean = false): Promise<IZosFilesResponse> {
const queryParams = new URLSearchParams(uri.query);
const ussPath = queryParams.has("searchPath") ? queryParams.get("searchPath") : uri.path.substring(uri.path.indexOf("/", 1));
if (ussPath.length === 0) {
throw new imperative.ImperativeError({
msg: vscode.l10n.t("Could not list USS files: Empty path provided in URI"),
});
}
const response = await ZoweExplorerApiRegister.getUssApi(profile).fileList(ussPath);
// If request was successful, create directories for the path if it doesn't exist
if (response.success && !keepRelative && response.apiResponse.items?.[0]?.mode?.startsWith("d") && !this.exists(uri)) {
await vscode.workspace.fs.createDirectory(uri);
let response: IZosFilesResponse;
try {
response = await ZoweExplorerApiRegister.getUssApi(profile).fileList(ussPath);
// If request was successful, create directories for the path if it doesn't exist
if (response.success && !keepRelative && response.apiResponse.items?.[0]?.mode?.startsWith("d") && !this.exists(uri)) {
await vscode.workspace.fs.createDirectory(uri.with({ query: "" }));
}
} catch (err) {
if (err instanceof Error) {
ZoweLogger.error(err.message);
}
throw err;
}

return {
Expand Down Expand Up @@ -169,7 +172,7 @@ export class UssFSProvider extends BaseProvider implements vscode.FileSystemProv
let parentDir = this._lookupParentDirectory(uri, true);
if (parentDir == null) {
const parentPath = path.posix.join(uri.path, "..");
const parentUri = uri.with({ path: parentPath });
const parentUri = uri.with({ path: parentPath, query: "" });
await vscode.workspace.fs.createDirectory(parentUri);
parentDir = this._lookupParentDirectory(uri, false);
parentDir.metadata = this._getInfoFromUri(parentUri);
Expand Down

0 comments on commit 8903d1d

Please sign in to comment.