@@ -81,41 +81,34 @@ async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScri
8181
8282 ( bool success , ulong size , HttpStatusCode status ) = await Utilities . GetDownloadSizeWithStatus ( dotnetScriptUrl ) ;
8383 if ( ! success ) {
84- string message ;
8584 if ( status == HttpStatusCode . NotFound ) {
86- message = $ "dotnet-install URL '{ dotnetScriptUrl } ' not found.";
85+ Log . WarningLine ( $ "dotnet-install URL '{ dotnetScriptUrl } ' not found.") ;
8786 } else {
88- message = $ "Failed to obtain dotnet-install script size from URL '{ dotnetScriptUrl } '. HTTP status code: { status } ({ ( int ) status } )";
87+ Log . WarningLine ( $ "Failed to obtain dotnet-install script size from URL '{ dotnetScriptUrl } '. HTTP status code: { status } ({ ( int ) status } )") ;
8988 }
9089
91- if ( ReportAndCheckCached ( message , quietOnError : true ) )
90+ if ( File . Exists ( dotnetScriptPath ) ) {
91+ Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
9292 return true ;
93+ }
9394 }
9495
9596 DownloadStatus downloadStatus = Utilities . SetupDownloadStatus ( context , size , context . InteractiveSession ) ;
9697 Log . StatusLine ( $ " { context . Characters . Link } { dotnetScriptUrl } ", ConsoleColor . White ) ;
9798 await Download ( context , dotnetScriptUrl , tempDotnetScriptPath , "dotnet-install" , Path . GetFileName ( dotnetScriptUrl . LocalPath ) , downloadStatus ) ;
9899
99- if ( ! File . Exists ( tempDotnetScriptPath ) ) {
100- return ReportAndCheckCached ( $ "Download of dotnet-install from { dotnetScriptUrl } failed") ;
100+ if ( File . Exists ( tempDotnetScriptPath ) ) {
101+ Utilities . CopyFile ( tempDotnetScriptPath , dotnetScriptPath ) ;
102+ Utilities . DeleteFile ( tempDotnetScriptPath ) ;
103+ return true ;
101104 }
102105
103- Utilities . CopyFile ( tempDotnetScriptPath , dotnetScriptPath ) ;
104- Utilities . DeleteFile ( tempDotnetScriptPath ) ;
105- return true ;
106-
107- bool ReportAndCheckCached ( string message , bool quietOnError = false )
108- {
109- if ( File . Exists ( dotnetScriptPath ) ) {
110- Log . WarningLine ( message ) ;
111- Log . WarningLine ( $ "Using cached installation script found in { dotnetScriptPath } ") ;
112- return true ;
113- }
114-
115- if ( ! quietOnError ) {
116- Log . ErrorLine ( message ) ;
117- Log . ErrorLine ( $ "Cached installation script not found in { dotnetScriptPath } ") ;
118- }
106+ if ( File . Exists ( dotnetScriptPath ) ) {
107+ Log . WarningLine ( $ "Download of dotnet-install from '{ dotnetScriptUrl } ' failed") ;
108+ Log . WarningLine ( $ "Using cached installation script found in '{ dotnetScriptPath } '") ;
109+ return true ;
110+ } else {
111+ Log . ErrorLine ( $ "Download of dotnet-install from '{ dotnetScriptUrl } ' failed") ;
119112 return false ;
120113 }
121114 }
@@ -196,7 +189,6 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
196189 string scriptFileName = Path . GetFileName ( dotnetScriptUrl . LocalPath ) ;
197190 string cachedDotnetScriptPath = Path . Combine ( cacheDir , scriptFileName ) ;
198191 if ( ! await DownloadDotNetInstallScript ( context , cachedDotnetScriptPath , dotnetScriptUrl ) ) {
199- Log . ErrorLine ( $ "Failed to download dotnet-install script.") ;
200192 return false ;
201193 }
202194
0 commit comments