Skip to content

Commit

Permalink
wip: reload workspaces once reauthenticated
Browse files Browse the repository at this point in the history
- note: may need to throttle amount of times the
reload is called, if you have a workspace with
hundreds of folders it will make a list request for
each one

Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Dec 19, 2024
1 parent 43eba14 commit cea4f85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/zowe-explorer-api/src/profiles/AuthHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import { Gui } from "../globals";
import { CorrelatedError } from "../utils";
import { CorrelatedError, reloadWorkspacesForProfile } from "../utils";
import * as imperative from "@zowe/imperative";
import { DeferredPromise } from "../utils";
import { IZoweTreeNode } from "../tree";
Expand Down Expand Up @@ -48,6 +48,8 @@ export class AuthHandler {
if (deferred) {
deferred.resolve();
this.lockedProfiles.delete(profileName);
// reload virtual workspaces for the profile now that its usable
await reloadWorkspacesForProfile(profileName);
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/zowe-explorer-api/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
*/

import { ZoweScheme } from "../fs";
import { IZoweTreeNode } from "../tree";
import { workspace } from "vscode";

Expand All @@ -26,3 +27,14 @@ export * from "./FileManagement";
export function isNodeInEditor(node: IZoweTreeNode): boolean {
return workspace.textDocuments.some(({ uri, isDirty }) => uri.path === node.resourceUri?.path && isDirty);
}

export async function reloadWorkspacesForProfile(profileName: string): Promise<void> {
const foldersWithProfile = (workspace.workspaceFolders ?? []).filter(
(f) => (f.uri.scheme === ZoweScheme.DS || f.uri.scheme === ZoweScheme.USS) && f.uri.path.startsWith(`/${profileName}/`)
);
for (const folder of foldersWithProfile) {
try {
await workspace.fs.stat(folder.uri.with({ query: "fetch=true" }));
} catch (err) {}
}
}

0 comments on commit cea4f85

Please sign in to comment.