@@ -43,6 +43,11 @@ type versionResponse struct {
4343 Linux string `json:"linux"`
4444 Macos string `json:"macos"`
4545 }
46+ Sizes struct {
47+ Windows int64 `json:"windows"`
48+ Linux int64 `json:"linux"`
49+ Macos int64 `json:"macos"`
50+ }
4651}
4752
4853type launcherConfig struct {
@@ -70,6 +75,7 @@ func (a *App) domReady(ctx context.Context) {
7075
7176func (a * App ) shutdown (ctx context.Context ) {
7277 cmd .Process .Kill ()
78+ os .Exit (1 )
7379}
7480
7581func hasArg (str string ) bool {
@@ -141,10 +147,9 @@ func PrintDownloadPercent(done chan int64, path string, total int64, ctx context
141147 }
142148
143149 var percent float64 = float64 (size ) / float64 (total ) * 100
144- runtime .EventsEmit (ctx , "launch_lilith" , fmt .Sprintf ("\r %.0f" , percent )+ "% Downloaded" )
145- runtime .EventsEmit (ctx , "lilith_log" , fmt .Sprintf ("\r [Launcher] %.0f" , percent )+ "% Downloaded" )
146- log .Printf ("\r %.0f" , percent )
147- print ("% Downloaded" )
150+ runtime .EventsEmit (ctx , "launch_lilith" , fmt .Sprintf ("%.0f%% Downloaded" , percent ))
151+ runtime .EventsEmit (ctx , "lilith_log" , fmt .Sprintf ("[Launcher] %.0f%% Downloaded" , percent ))
152+ runtime .LogInfo (ctx , fmt .Sprintf ("\r %.0f" , percent ))
148153 }
149154
150155 if stop {
@@ -181,6 +186,10 @@ func (a *App) HandleErrorFrontend(err string) {
181186 })
182187}
183188
189+ func (a * App ) GetVersion () string {
190+ return update .Version
191+ }
192+
184193func (a * App ) HTTPGetRequest (url string ) (string , error ) {
185194 resp , err := http .Get (url )
186195 if err != nil {
@@ -291,6 +300,18 @@ func (a *App) LaunchLilith() (string, error) {
291300 default :
292301 download = f .Download .Linux
293302 }
303+
304+ var size int64
305+ switch goruntime .GOOS {
306+ case "windows" :
307+ size = f .Sizes .Windows
308+ case "darwin" :
309+ size = f .Sizes .Macos
310+ case "linux" :
311+ size = f .Sizes .Linux
312+ default :
313+ size = f .Sizes .Linux
314+ }
294315
295316 filename := download [strings .LastIndex (download , "/" )+ 1 :]
296317 runtime .EventsEmit (a .ctx , "launch_lilith" , "Lilith is now running" )
@@ -314,8 +335,24 @@ func (a *App) LaunchLilith() (string, error) {
314335 runtime .EventsEmit (a .ctx , "launch_lilith" , "Launching lilith " + f .Version )
315336 runtime .EventsEmit (a .ctx , "launch_lilith" , "Lilith is now running" )
316337 runtime .EventsEmit (a .ctx , "lilith_log" , "[Launcher] Lilith has started" )
317- runtime .LogInfo (a .ctx , "\r 100% Downloaded " )
338+ runtime .LogInfo (a .ctx , "\r Download Complete " )
318339 path = bindir + "/" + filename
340+ } else {
341+ fi , _ := os .Stat (path )
342+ if (fi .Size () != size ) {
343+ err := os .Remove (path )
344+ a .HandleError (err )
345+ runtime .LogInfo (a .ctx , "Couldn't find the latest Lilith version, downloading..." )
346+ runtime .EventsEmit (a .ctx , "launch_lilith" , "Downloading lilith " + f .Version )
347+ runtime .EventsEmit (a .ctx , "lilith_log" , "[Launcher] Downloading lilith " + f .Version )
348+ err = DownloadFile (bindir + "/" + filename , download , a .ctx )
349+ a .HandleError (err )
350+ runtime .EventsEmit (a .ctx , "launch_lilith" , "Launching lilith " + f .Version )
351+ runtime .EventsEmit (a .ctx , "launch_lilith" , "Lilith is now running" )
352+ runtime .EventsEmit (a .ctx , "lilith_log" , "[Launcher] Lilith has started" )
353+ runtime .LogInfo (a .ctx , "\r Download Complete" )
354+ path = bindir + "/" + filename
355+ }
319356 }
320357
321358 if goruntime .GOOS != "windows" {
0 commit comments