@@ -578,13 +578,8 @@ async function updateStatus(context: vscode.ExtensionContext): Promise<void> {
578578}
579579
580580async function getMirrors ( context : vscode . ExtensionContext ) : Promise < vscode . Uri [ ] > {
581- let cached = { timestamp : 0 , mirrors : "" } ;
582- const key = "mirror-cache" ;
583-
584- const cachedStr = context . globalState . get < string > ( key ) ;
585- if ( cachedStr !== undefined ) {
586- cached = JSON . parse ( cachedStr ) as typeof cached ;
587- }
581+ const key = "zig-mirror-cache" ;
582+ let cached = context . globalState . get ( key , { timestamp : 0 , mirrors : "" } ) ;
588583
589584 const millisecondsInDay = 24 * 60 * 60 * 1000 ;
590585 if ( new Date ( ) . getTime ( ) - cached . timestamp > millisecondsInDay ) {
@@ -596,7 +591,7 @@ async function getMirrors(context: vscode.ExtensionContext): Promise<vscode.Uri[
596591 timestamp : new Date ( ) . getTime ( ) ,
597592 mirrors : mirrorList ,
598593 } ;
599- context . globalState . update ( key , JSON . stringify ( cached ) ) ;
594+ context . globalState . update ( key , cached ) ;
600595 } catch {
601596 // Cannot fetch mirrors, rely on cache.
602597 }
@@ -605,6 +600,7 @@ async function getMirrors(context: vscode.ExtensionContext): Promise<vscode.Uri[
605600 return cached . mirrors
606601 . trim ( )
607602 . split ( "\n" )
603+ . filter ( ( u ) => ! ! u )
608604 . map ( ( u ) => vscode . Uri . parse ( u ) ) ;
609605}
610606
@@ -713,7 +709,9 @@ export async function setupZig(context: vscode.ExtensionContext) {
713709 /** https://ziglang.org/download */
714710 minisignKey : minisign . parseKey ( "RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U" ) ,
715711 versionArg : "version" ,
716- mirrorUrls : await getMirrors ( context ) ,
712+ getMirrorUrls ( ) {
713+ return getMirrors ( context ) ;
714+ } ,
717715 canonicalUrl : {
718716 release : vscode . Uri . parse ( "https://ziglang.org/download" ) ,
719717 nightly : vscode . Uri . parse ( "https://ziglang.org/builds" ) ,
0 commit comments