@@ -9,15 +9,16 @@ import { createProgress } from "../utils/progress";
99import { formatBytes } from "../utils/formatBytes" ;
1010import { checkFileOrFolderExists , getChecksum , getSaveFolder } from "./utils" ;
1111import Logger from "../logger" ;
12- import { TypeModel } from "../server" ;
12+ import type { TypeModel } from "../server" ;
1313import { configuration } from "../utils/configuration" ;
14+ import { state } from "../utils/state" ;
1415
1516interface ResourceInfo {
1617 url : string ;
1718 checksum : string ;
1819}
1920
20- interface Spec {
21+ export interface Spec {
2122 linux : {
2223 "x86-64" : {
2324 cpu : ResourceInfo ;
@@ -84,17 +85,26 @@ const downloadFileWithProgress = async (
8485const getServerInfo = async ( ) : Promise < ResourceInfo | null > => {
8586 const osplatform = os . platform ( ) ;
8687 const osmachine = os . machine ( ) ;
88+ let spec : Spec | null = null ;
89+ try {
90+ const response = await fetch (
91+ "https://pub-ad9e0b7360bc4259878d0f81b89c5405.r2.dev/spec.json"
92+ ) ;
8793
88- const response = await fetch (
89- "https://pub-ad9e0b7360bc4259878d0f81b89c5405.r2.dev/spec.json"
90- ) ;
94+ if ( ! response . ok ) {
95+ return null ;
96+ }
9197
92- if ( ! response . ok ) {
98+ spec = ( await response . json ( ) ) as Spec ;
99+ await state . global . update ( "serverSpec" , spec ) ;
100+ } catch ( error ) {
101+ spec = state . global . get ( "serverSpec" ) ;
102+ Logger . warn ( `Can not get server spec` ) ;
103+ }
104+ if ( spec === null ) {
93105 return null ;
94106 }
95107
96- const spec = ( await response . json ( ) ) as Spec ;
97-
98108 if ( osplatform === "win32" ) {
99109 if ( osmachine === "x86_64" ) {
100110 const useGPUNvidia = configuration . get (
0 commit comments