From 55695e93486e3843d9c6a675617b0fc6960553f1 Mon Sep 17 00:00:00 2001 From: HarithaVattikuti <73516759+HarithaVattikuti@users.noreply.github.com> Date: Wed, 25 Dec 2024 22:12:57 -0600 Subject: [PATCH] Add Fallback logic --- dist/index.js | 11 +++++++++-- src/installer.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4344db7..a45fa28 100644 --- a/dist/index.js +++ b/dist/index.js @@ -18168,7 +18168,13 @@ class DotnetCoreInstaller { } getReleasesJsonUrl(httpClient, versionParts) { return __awaiter(this, void 0, void 0, function* () { - const response = yield httpClient.getJson(DotNetCoreIndexUrl); + let response; + try { + response = yield httpClient.getJson(DotNetCoreIndexUrl); + } + catch (error) { + response = yield httpClient.getJson(DotnetCoreIndexFallbackUrl); + } const result = response.result || {}; let releasesInfo = result['releases-index']; releasesInfo = releasesInfo.filter((info) => { @@ -18192,7 +18198,8 @@ class DotnetCoreInstaller { } } exports.DotnetCoreInstaller = DotnetCoreInstaller; -const DotNetCoreIndexUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; +const DotNetCoreIndexUrl = 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; +const DotnetCoreIndexFallbackUrl = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'; /***/ }), diff --git a/src/installer.ts b/src/installer.ts index c25d23a..bb08542 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -261,7 +261,12 @@ export class DotnetCoreInstaller { httpClient: hc.HttpClient, versionParts: string[] ): Promise { - const response = await httpClient.getJson(DotNetCoreIndexUrl); + let response; + try { + response = await httpClient.getJson(DotNetCoreIndexUrl); + } catch (error) { + response = await httpClient.getJson(DotnetCoreIndexFallbackUrl); + } const result = response.result || {}; let releasesInfo: any[] = result['releases-index']; @@ -300,4 +305,7 @@ export class DotnetCoreInstaller { } const DotNetCoreIndexUrl: string = + 'https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json'; + +const DotnetCoreIndexFallbackUrl: string = 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json';