Skip to content

Commit b1a234f

Browse files
Gracefully handle virtual /Repos/me folder (#693)
## Changes The extension tries to find the root folder (/Repos/me or /Users/me/.ide) depending on what the sync destination type is (repos or workspace). The current root is stored in `currentFsRoot`. In case it fails in finding the `currentFsRoot` (/Repos/me and /Users/me can be virtual when a user hasn't interacted with these folders yet), it always tries to create it under /User/me. This can be an issue if `currentFsRoot` points to /Repos/me. * This PR fixes this behaviour, by only allowing creation of `workspaceFsRoot` (which always points to /Users/me/.ide) under /User/me and not `currentFsRoot`. * Also fix error reporting to show more verbose errors. Creating a repo from the extension automatically handles generation of /Repos/me folder as well. Fixes #683 #691 #688 ## Tests * Manually verified to work after the change. --------- Co-authored-by: Fabian Jakobs <fabian.jakobs@databricks.com>
1 parent a5a9dbd commit b1a234f

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

packages/databricks-vscode/src/configuration/ConnectionManager.ts

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ export class ConnectionManager {
106106
try {
107107
await this._login(interactive, force);
108108
} catch (e) {
109-
NamedLogger.getOrCreate("Extension").error("Login Error", e);
110-
if (interactive) {
111-
window.showErrorMessage(`Login error ${JSON.stringify(e)}`);
109+
NamedLogger.getOrCreate("Extension").error("Login Error:", e);
110+
if (interactive && e instanceof Error) {
111+
window.showErrorMessage(`Login error: ${e.message}`);
112112
}
113113
this.updateState("DISCONNECTED");
114114
await this.logout();
@@ -220,44 +220,39 @@ export class ConnectionManager {
220220
this.updateSyncDestination(undefined);
221221
}
222222

223-
if (
224-
this.databricksWorkspace &&
225-
(workspaceConfigs.enableFilesInWorkspace ||
226-
this.workspaceState.wsfsFeatureFlag)
227-
) {
228-
await this.createRootDirectory(
229-
workspaceClient,
230-
this.databricksWorkspace.currentFsRoot,
231-
this.databricksWorkspace.userName
232-
);
233-
}
234-
223+
await this.createWsFsRootDirectory(workspaceClient);
235224
this.updateState("CONNECTED");
236225
}
237226

238-
async createRootDirectory(
239-
wsClient: WorkspaceClient,
240-
rootDirPath: RemoteUri,
241-
me: string
242-
) {
227+
async createWsFsRootDirectory(wsClient: WorkspaceClient) {
228+
if (
229+
!this.databricksWorkspace ||
230+
!(
231+
workspaceConfigs.enableFilesInWorkspace ||
232+
this.workspaceState.wsfsFeatureFlag
233+
)
234+
) {
235+
return;
236+
}
237+
const rootDirPath = this.databricksWorkspace.workspaceFsRoot;
238+
const me = this.databricksWorkspace.userName;
243239
let rootDir = await WorkspaceFsEntity.fromPath(
244240
wsClient,
245241
rootDirPath.path
246242
);
243+
if (rootDir) {
244+
return;
245+
}
246+
const meDir = await WorkspaceFsEntity.fromPath(
247+
wsClient,
248+
`/Users/${me}`
249+
);
250+
if (WorkspaceFsUtils.isDirectory(meDir)) {
251+
rootDir = await meDir.mkdir(rootDirPath.path);
252+
}
247253
if (!rootDir) {
248-
const meDir = await WorkspaceFsEntity.fromPath(
249-
wsClient,
250-
`/Users/${me}`
251-
);
252-
if (WorkspaceFsUtils.isDirectory(meDir)) {
253-
rootDir = await meDir.mkdir(rootDirPath.path);
254-
}
255-
if (!rootDir) {
256-
window.showErrorMessage(
257-
`Can't find or create ${rootDirPath.path}`
258-
);
259-
return;
260-
}
254+
window.showErrorMessage(`Can't find or create ${rootDirPath.path}`);
255+
return;
261256
}
262257
}
263258

0 commit comments

Comments
 (0)