@@ -78,41 +78,34 @@ async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScri
7878
7979 ( bool success , ulong size , HttpStatusCode status ) = await Utilities . GetDownloadSizeWithStatus ( dotnetScriptUrl ) ;
8080 if ( ! success ) {
81- string message ;
8281 if ( status == HttpStatusCode . NotFound ) {
83- message = $ "dotnet-install URL '{ dotnetScriptUrl } ' not found.";
82+ Log . WarningLine ( $ "dotnet-install URL '{ dotnetScriptUrl } ' not found.") ;
8483 } else {
85- message = $ "Failed to obtain dotnet-install script size from URL '{ dotnetScriptUrl } '. HTTP status code: { status } ({ ( int ) status } )";
84+ Log . WarningLine ( $ "Failed to obtain dotnet-install script size from URL '{ dotnetScriptUrl } '. HTTP status code: { status } ({ ( int ) status } )") ;
8685 }
8786
88- if ( ReportAndCheckCached ( message , quietOnError : true ) )
87+ if ( File . Exists ( dotnetScriptPath ) ) {
88+ Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
8989 return true ;
90+ }
9091 }
9192
9293 DownloadStatus downloadStatus = Utilities . SetupDownloadStatus ( context , size , context . InteractiveSession ) ;
9394 Log . StatusLine ( $ " { context . Characters . Link } { dotnetScriptUrl } ", ConsoleColor . White ) ;
9495 await Download ( context , dotnetScriptUrl , tempDotnetScriptPath , "dotnet-install" , Path . GetFileName ( dotnetScriptUrl . LocalPath ) , downloadStatus ) ;
9596
96- if ( ! File . Exists ( tempDotnetScriptPath ) ) {
97- return ReportAndCheckCached ( $ "Download of dotnet-install from { dotnetScriptUrl } failed") ;
97+ if ( File . Exists ( tempDotnetScriptPath ) ) {
98+ Utilities . CopyFile ( tempDotnetScriptPath , dotnetScriptPath ) ;
99+ Utilities . DeleteFile ( tempDotnetScriptPath ) ;
100+ return true ;
98101 }
99102
100- Utilities . CopyFile ( tempDotnetScriptPath , dotnetScriptPath ) ;
101- Utilities . DeleteFile ( tempDotnetScriptPath ) ;
102- return true ;
103-
104- bool ReportAndCheckCached ( string message , bool quietOnError = false )
105- {
106- if ( File . Exists ( dotnetScriptPath ) ) {
107- Log . WarningLine ( message ) ;
108- Log . WarningLine ( $ "Using cached installation script found in { dotnetScriptPath } ") ;
109- return true ;
110- }
111-
112- if ( ! quietOnError ) {
113- Log . ErrorLine ( message ) ;
114- Log . ErrorLine ( $ "Cached installation script not found in { dotnetScriptPath } ") ;
115- }
103+ if ( File . Exists ( dotnetScriptPath ) ) {
104+ Log . WarningLine ( $ "Download of dotnet-install from '{ dotnetScriptUrl } ' failed") ;
105+ Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
106+ return true ;
107+ } else {
108+ Log . ErrorLine ( $ "Download of dotnet-install from '{ dotnetScriptUrl } ' failed") ;
116109 return false ;
117110 }
118111 }
@@ -193,7 +186,6 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
193186 string scriptFileName = Path . GetFileName ( dotnetScriptUrl . LocalPath ) ;
194187 string cachedDotnetScriptPath = Path . Combine ( cacheDir , scriptFileName ) ;
195188 if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl ) ) {
196- Log . ErrorLine ( $ "Failed to download dotnet-install script.") ;
197189 return false ;
198190 }
199191
0 commit comments