@@ -189,7 +189,7 @@ impl SysBackend for WebBackend {
189
189
stdout. push ( OutputItem :: String ( line. into ( ) ) ) ;
190
190
}
191
191
if s. ends_with ( '\n' ) {
192
- stdout. push ( OutputItem :: String ( "" . into ( ) ) ) ;
192
+ stdout. push ( OutputItem :: String ( String :: new ( ) ) ) ;
193
193
}
194
194
Ok ( ( ) )
195
195
}
@@ -510,64 +510,61 @@ impl SysBackend for WebBackend {
510
510
) )
511
511
. await ;
512
512
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 ( ) ) ) ;
516
538
unmark_working ( & original_url) ;
517
539
return ;
518
540
}
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
- }
543
541
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 ;
561
559
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
+ }
566
564
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) ;
571
568
}
572
569
}
573
570
}
0 commit comments