Skip to content

Commit 04657c2

Browse files
committed
Cache the user
Signed-off-by: David Gageot <[email protected]>
1 parent c2f2a98 commit 04657c2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/extension/ui/src/FileUtils.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ export const tryRunImageSync = async (client: v1.DockerDesktopClient, args: stri
2828
}
2929
}
3030

31+
let user: string | null = null;
32+
3133
export const getUser = async (client: v1.DockerDesktopClient) => {
32-
const result = await tryRunImageSync(client, ['--rm', '-e', 'USER', BUSYBOX, '/bin/echo', '$USER'])
33-
return result.trim()
34-
}
34+
if (user == null) {
35+
const result = await tryRunImageSync(client, ['--rm', '-e', 'USER', BUSYBOX, '/bin/echo', '$USER']);
36+
user = result.trim();
37+
}
38+
return user;
39+
};
3540

3641
export const readFileInPromptsVolume = async (client: v1.DockerDesktopClient, path: string) => {
3742
return tryRunImageSync(client, ['--rm', '-v', 'docker-prompts:/docker-prompts', '-w', '/docker-prompts', BUSYBOX, '/bin/cat', `${path}`], true)

0 commit comments

Comments
 (0)