Skip to content

Commit 83dac0f

Browse files
committed
Prevent crash when loading workspace with deleted folder
Fixes #3356 Signed-off-by: David Thompson <[email protected]>
1 parent ac8d24a commit 83dac0f

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Change Log
22

3-
## 1.9.1 (September 27, 2023)
3+
## 1.9.1 (September 28, 2023)
44
* [#3342](https://github.com/redhat-developer/vscode-openshift-tools/issues/3342) Sandbox page in `Add OpenShift Cluster` editor stays in 'Detecting' status forever.
5+
* [#3356](https://github.com/redhat-developer/vscode-openshift-tools/issues/3356) Extension fails to activate when a deleted folder is in the workspace.
56

67
## 1.9.0 (September 26, 2023)
78
* [#3086](https://github.com/redhat-developer/vscode-openshift-tools/issues/3086) In Devfile search view, you can now filter by debug/deploy support and tags.
@@ -141,7 +142,7 @@
141142
* [#2718](https://github.com/redhat-developer/vscode-openshift-tools/issues/2718) Is it possible to change the colors of the YML keys?
142143
* [#2711](https://github.com/redhat-developer/vscode-openshift-tools/issues/2711) Migrate to odo 3.4.0
143144
* [#2710](https://github.com/redhat-developer/vscode-openshift-tools/issues/2710) remove patternfly dependencies from OpenShift Toolkit
144-
* [#2709](https://github.com/redhat-developer/vscode-openshift-tools/issues/2709) Fix the GitHub Readme badge error
145+
* [#2709](https://github.com/redhat-developer/vscode-openshift-tools/issues/2709) Fix the GitHub Readme badge error
145146
* [#2705](https://github.com/redhat-developer/vscode-openshift-tools/issues/2705) Devfile Registry View does not show errors for connectivity related issues and stays in 'Loading Registry View' mode forever
146147
* [#2701](https://github.com/redhat-developer/vscode-openshift-tools/issues/2701) Show and Follow log is not shown when set to open in web view
147148
* [#2700](https://github.com/redhat-developer/vscode-openshift-tools/issues/2700) Missing word in error message in Import from Git wizard
@@ -156,7 +157,7 @@
156157
* [#2674](https://github.com/redhat-developer/vscode-openshift-tools/issues/2674) Unable to select devfile registry in git import when multiple devfile registry configured
157158
* [#2671](https://github.com/redhat-developer/vscode-openshift-tools/issues/2671) Unable to create component from Get started page view
158159
* [#2667](https://github.com/redhat-developer/vscode-openshift-tools/issues/2667) Support odo 3.2.0 workflow
159-
* [#2666](https://github.com/redhat-developer/vscode-openshift-tools/issues/2666) Typo: Component name spell error
160+
* [#2666](https://github.com/redhat-developer/vscode-openshift-tools/issues/2666) Typo: Component name spell error
160161
* [#2608](https://github.com/redhat-developer/vscode-openshift-tools/issues/2608) Debug session failed to start
161162
* [#2598](https://github.com/redhat-developer/vscode-openshift-tools/issues/2598) Manage Kubernetes Context Action
162163
* [#2579](https://github.com/redhat-developer/vscode-openshift-tools/issues/2579) Add Browse actions in registry view
@@ -187,7 +188,7 @@
187188
* [#2593](https://github.com/redhat-developer/vscode-openshift-tools/issues/2593) Open .kubeconfig in editor
188189
* [#2591](https://github.com/redhat-developer/vscode-openshift-tools/issues/2591) Update Readme with 1.0 changes and odov3 support
189190
* [#2590](https://github.com/redhat-developer/vscode-openshift-tools/issues/2590) Follow logs commands fails with error
190-
* [#2588](https://github.com/redhat-developer/vscode-openshift-tools/issues/2588) Odo logo output is missing in terminal when starting dev on k8s cluster
191+
* [#2588](https://github.com/redhat-developer/vscode-openshift-tools/issues/2588) Odo logo output is missing in terminal when starting dev on k8s cluster
191192
* [#2582](https://github.com/redhat-developer/vscode-openshift-tools/issues/2582) Show the application explorer using the cluster and project structure
192193
* [#2580](https://github.com/redhat-developer/vscode-openshift-tools/issues/2580) Force stop dev fails with the following error
193194
* [#2578](https://github.com/redhat-developer/vscode-openshift-tools/issues/2578) Created component notification says is should be pushed into cluster, wrong description
@@ -228,7 +229,7 @@
228229
* [#2486](https://github.com/redhat-developer/vscode-openshift-tools/issues/2486) Fix UI responsiveness for Add Cluster screen
229230
* [#2480](https://github.com/redhat-developer/vscode-openshift-tools/issues/2480) Activate basic UI tests in GitHub Actions workflow
230231
* [#2474](https://github.com/redhat-developer/vscode-openshift-tools/issues/2474) Launching Developer Sandbox feature does not work
231-
* [#2450](https://github.com/redhat-developer/vscode-openshift-tools/issues/2450) Migrate to latest CRC 2.4.1 release
232+
* [#2450](https://github.com/redhat-developer/vscode-openshift-tools/issues/2450) Migrate to latest CRC 2.4.1 release
232233
* [#2421](https://github.com/redhat-developer/vscode-openshift-tools/issues/2421) Review telemetry events to eliminate not used ones
233234
* [#2404](https://github.com/redhat-developer/vscode-openshift-tools/issues/2404) Change New Component workflow
234235
* [#1477](https://github.com/redhat-developer/vscode-openshift-tools/issues/1477) 'OpenShift: Delete Storage' command should not delete storage from tree until it is pushed
@@ -265,7 +266,7 @@
265266

266267
## 0.3.0 (February 28, 2022)
267268

268-
* [#2361](https://github.com/redhat-developer/vscode-openshift-tools/issues/2361) SandBox code verification page shows all button on the same line for wide screens
269+
* [#2361](https://github.com/redhat-developer/vscode-openshift-tools/issues/2361) SandBox code verification page shows all button on the same line for wide screens
269270
* [#2359](https://github.com/redhat-developer/vscode-openshift-tools/issues/2359) OpenShift Sandbox Cluster has no active project after login
270271
* [#2350](https://github.com/redhat-developer/vscode-openshift-tools/issues/2350) Sandbox view is broken after second click on `Add Cluster` Button
271272
* [#2344](https://github.com/redhat-developer/vscode-openshift-tools/issues/2344) Error message appears for odo verbosity level values > 0
@@ -283,7 +284,7 @@
283284
* [#2254](https://github.com/redhat-developer/vscode-openshift-tools/issues/2254) Add Create Service Form support for user without access to service CRDs
284285
* [#2246](https://github.com/redhat-developer/vscode-openshift-tools/issues/2246) Provide warning/info about kubeadmin user for service workflow
285286
* [#2238](https://github.com/redhat-developer/vscode-openshift-tools/issues/2238) Remove info about Git Repository and Binary File component creation in readme
286-
* [#2228](https://github.com/redhat-developer/vscode-openshift-tools/issues/2228) Are Git Repository and Binary File options removed when creating a component from Openshift Connector extension?
287+
* [#2228](https://github.com/redhat-developer/vscode-openshift-tools/issues/2228) Are Git Repository and Binary File options removed when creating a component from Openshift Connector extension?
287288
* [#2208](https://github.com/redhat-developer/vscode-openshift-tools/issues/2208) Remove service catalog support related commands
288289
* [#2007](https://github.com/redhat-developer/vscode-openshift-tools/issues/2007) 'Open in Readme.md in Browser' for S2I Component Type
289290
* [#1967](https://github.com/redhat-developer/vscode-openshift-tools/issues/1967) Add quickpick item 'Login using cluster URL and token from clipboard' to login command
@@ -331,7 +332,7 @@
331332

332333
### Bug fixes
333334

334-
* [#2213](https://github.com/redhat-developer/vscode-openshift-tools/issues/2213) DevSandbox page fails
335+
* [#2213](https://github.com/redhat-developer/vscode-openshift-tools/issues/2213) DevSandbox page fails
335336
* [#2177](https://github.com/redhat-developer/vscode-openshift-tools/issues/2177) Objects deleted from App Explorer tree have not deleted from parent->children cache
336337
* [#2167](https://github.com/redhat-developer/vscode-openshift-tools/issues/2167) Option to prevent removing project folder from workspace when deleting component
337338

src/serverlessFunction/functionModel.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as fs from 'fs-extra';
77
import * as path from 'path';
8-
import { Disposable, Uri, workspace } from 'vscode';
8+
import { Disposable, Uri, window, workspace } from 'vscode';
99
import { CommandText } from '../base/command';
1010
import { CliChannel } from '../cli';
1111
import { DeploymentConfig } from '../k8s/deploymentConfig';
@@ -123,13 +123,23 @@ export class ServerlessFunctionModel implements Disposable {
123123
private addWatchers() {
124124
if (workspace.workspaceFolders) {
125125
for (const workspaceFolder of workspace.workspaceFolders) {
126-
this.watchers.push(
127-
fs.watch(workspaceFolder.uri.fsPath, (_event, filename) => {
128-
if (filename === 'func.yaml') {
129-
this.view.refresh();
130-
}
131-
}),
132-
);
126+
let folderExists = false;
127+
try {
128+
fs.accessSync(workspaceFolder.uri.fsPath);
129+
folderExists = true;
130+
} catch (e) {
131+
// folder doesn't exist
132+
void window.showErrorMessage(`Can't keep track of if '${path.basename(workspaceFolder.uri.fsPath)}' contains a serverless function, since it's been deleted.`);
133+
}
134+
if (folderExists) {
135+
this.watchers.push(
136+
fs.watch(workspaceFolder.uri.fsPath, (_event, filename) => {
137+
if (filename === 'func.yaml') {
138+
this.view.refresh();
139+
}
140+
}),
141+
);
142+
}
133143
}
134144
}
135145
}

0 commit comments

Comments
 (0)