File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -561,9 +561,14 @@ async fn prep_launch(
561561 state. proxy = Some ( handle) ;
562562 }
563563
564- // Upgrade the main URL to HTTPS, since ffrunner supports it
564+ // Upgrade the main URL to HTTPS, if it's available, since ffrunner supports it
565565 if main_url. starts_with ( "http://" ) {
566- main_url = main_url. replacen ( "http://" , "https://" , 1 ) ;
566+ let main_url_upgraded = main_url. replacen ( "http://" , "https://" , 1 ) ;
567+ if util:: does_web_file_exist ( & main_url_upgraded) . await {
568+ main_url = main_url_upgraded;
569+ } else if !util:: does_web_file_exist ( & main_url) . await {
570+ return Err ( format ! ( "Main file not found: {}" , main_url) . into ( ) ) ;
571+ }
567572 }
568573
569574 debug ! ( "Asset URL: {}" , asset_url) ;
Original file line number Diff line number Diff line change @@ -554,3 +554,14 @@ pub(crate) fn log_command(command: &Command) {
554554 let command_str = get_launch_cmd_dbg_str ( command, true ) ;
555555 debug ! ( "Launching game: {}" , command_str) ;
556556}
557+
558+ pub ( crate ) async fn does_web_file_exist ( url : & str ) -> bool {
559+ let client = get_http_client ( ) ;
560+ match client. head ( url) . send ( ) . await {
561+ Ok ( response) => response. status ( ) . is_success ( ) ,
562+ Err ( e) => {
563+ debug ! ( "Failed to check if web file exists: {}" , e) ;
564+ false
565+ }
566+ }
567+ }
You can’t perform that action at this time.
0 commit comments