@@ -189,7 +189,7 @@ impl SysBackend for WebBackend {
189189 stdout. push ( OutputItem :: String ( line. into ( ) ) ) ;
190190 }
191191 if s. ends_with ( '\n' ) {
192- stdout. push ( OutputItem :: String ( "" . into ( ) ) ) ;
192+ stdout. push ( OutputItem :: String ( String :: new ( ) ) ) ;
193193 }
194194 Ok ( ( ) )
195195 }
@@ -510,64 +510,61 @@ impl SysBackend for WebBackend {
510510 ) )
511511 . await ;
512512
513- match tree_res {
514- Err ( _) => {
515- cache_url ( & url, tree_res) ;
513+ if tree_res. is_err ( ) {
514+ cache_url ( & url, tree_res) ;
515+ unmark_working ( & original_url) ;
516+ return ;
517+ } else {
518+ let tree = tree_res. unwrap ( ) ;
519+ let tree: serde_json:: Value = serde_json:: from_str ( & tree) . unwrap ( ) ;
520+ let tree = tree. get ( "tree" ) . unwrap ( ) . as_array ( ) . unwrap ( ) ;
521+ let paths = tree
522+ . iter ( )
523+ . filter_map ( |entry| {
524+ let path = entry. get ( "path" ) ?. as_str ( ) ?;
525+ if Path :: new ( path)
526+ . extension ( )
527+ . is_some_and ( |ext| ext. eq_ignore_ascii_case ( "ua" ) )
528+ {
529+ Some ( path. to_string ( ) )
530+ } else {
531+ None
532+ }
533+ } )
534+ . collect :: < HashSet < _ > > ( ) ;
535+
536+ if !paths. contains ( "lib.ua" ) {
537+ cache_url ( & url, Err ( "lib.ua not found" . into ( ) ) ) ;
516538 unmark_working ( & original_url) ;
517539 return ;
518540 }
519- Ok ( _) => {
520- let tree = tree_res. unwrap ( ) ;
521- let tree: serde_json:: Value = serde_json:: from_str ( & tree) . unwrap ( ) ;
522- let tree = tree. get ( "tree" ) . unwrap ( ) . as_array ( ) . unwrap ( ) ;
523- let paths = tree
524- . iter ( )
525- . filter_map ( |entry| {
526- let path = entry. get ( "path" ) ?. as_str ( ) ?;
527- if Path :: new ( path)
528- . extension ( )
529- . is_some_and ( |ext| ext. eq_ignore_ascii_case ( "ua" ) )
530- {
531- Some ( path. to_string ( ) )
532- } else {
533- None
534- }
535- } )
536- . collect :: < HashSet < _ > > ( ) ;
537-
538- if !paths. contains ( "lib.ua" ) {
539- cache_url ( & url, Err ( "lib.ua not found" . into ( ) ) ) ;
540- unmark_working ( & original_url) ;
541- return ;
542- }
543541
544- let results = join_all ( paths. iter ( ) . map ( |path| {
545- let repo_owner = repo_owner. clone ( ) ;
546- let repo_name = repo_name. clone ( ) ;
547- async move {
548- let fetch_url = format ! (
549- "https://raw.githubusercontent.com\
550- /{repo_owner}/{repo_name}/main/{path}",
551- ) ;
552- let internal_path = Path :: new ( "uiua-modules" )
553- . join ( repo_owner)
554- . join ( repo_name)
555- . join ( path. clone ( ) ) ;
556-
557- ( path, internal_path, fetch ( fetch_url. as_str ( ) ) . await )
558- }
559- } ) )
560- . await ;
542+ let results = join_all ( paths. iter ( ) . map ( |path| {
543+ let repo_owner = repo_owner. clone ( ) ;
544+ let repo_name = repo_name. clone ( ) ;
545+ async move {
546+ let fetch_url = format ! (
547+ "https://raw.githubusercontent.com\
548+ /{repo_owner}/{repo_name}/main/{path}",
549+ ) ;
550+ let internal_path = Path :: new ( "uiua-modules" )
551+ . join ( repo_owner)
552+ . join ( repo_name)
553+ . join ( path. clone ( ) ) ;
554+
555+ ( path, internal_path, fetch ( fetch_url. as_str ( ) ) . await )
556+ }
557+ } ) )
558+ . await ;
561559
562- for ( original_path, internal_path, res) in results {
563- if original_path. eq ( "lib.ua" ) {
564- cache_url ( & url, res. clone ( ) ) ;
565- }
560+ for ( original_path, internal_path, res) in results {
561+ if original_path. eq ( "lib.ua" ) {
562+ cache_url ( & url, res. clone ( ) ) ;
563+ }
566564
567- if let Ok ( text) = res {
568- let contents = text. as_bytes ( ) . to_vec ( ) ;
569- drop_file ( internal_path. clone ( ) , contents) ;
570- }
565+ if let Ok ( text) = res {
566+ let contents = text. as_bytes ( ) . to_vec ( ) ;
567+ drop_file ( internal_path. clone ( ) , contents) ;
571568 }
572569 }
573570 }
0 commit comments