Skip to content

Commit 7ab1d8b

Browse files
committed
fallback to default repo in error cases with FSPs
1 parent 960a092 commit 7ab1d8b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/common/pythonInstallation.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,21 @@ namespace PythonInstallation {
2323
pythonRoot = defaultPythonRoot;
2424
}
2525

26+
// Consider third party file system providers
2627
const pythonRepositoryUri = Uri.parse(pythonRepository);
2728
if (Uri.parse(pythonRepository).authority !== 'github.com') {
28-
return { repository: pythonRepositoryUri, root: '/'};
29+
const binaryLocation = Uri.joinPath(pythonRepositoryUri, 'python.wasm');
30+
try {
31+
// fs.stat throws if file doesn't exist
32+
await workspace.fs.stat(binaryLocation);
33+
return { repository: pythonRepositoryUri, root: '/'};
34+
} catch {
35+
Tracer.append(`python.wasm not found in ${binaryLocation}. Falling back to default repository`);
36+
pythonRepository = defaultPythonRepository;
37+
pythonRoot = defaultPythonRoot;
38+
}
2939
}
40+
3041
const extname = path.extname(pythonRepository);
3142
if (extname === '.git') {
3243
pythonRepository = pythonRepository.substring(0, pythonRepository.length - extname.length);

0 commit comments

Comments
 (0)