Adds self-hosted update system

Implements a self-hosted update mechanism, allowing the application to be updated from a corporate network share without relying on third-party services.

This includes:
- Functionality to check for updates
- Download installers
- Verify checksums
- Install updates with UAC elevation

Configuration is managed via the config.ini file, with automatic checks on startup. A new settings UI is also included.
This commit is contained in:
Flavio Fois
2026-02-06 18:50:11 +01:00
parent 43cce905eb
commit 0cfe1b65f3
12 changed files with 1113 additions and 12 deletions

32
app.go
View File

@@ -4,9 +4,11 @@ package main
import (
"context"
"log"
"os"
"strings"
"sync"
"time"
"emly/backend/utils"
@@ -91,6 +93,36 @@ func (a *App) startup(ctx context.Context) {
Log("Viewer instance started")
} else {
Log("EMLy main application started")
// Automatic update check on startup (if enabled)
go func() {
// Wait 5 seconds after startup to avoid blocking the UI
time.Sleep(5 * time.Second)
config := a.GetConfig()
if config == nil {
log.Printf("Failed to load config for auto-update check")
return
}
// Check if auto-update is enabled
if config.EMLy.UpdateAutoCheck == "true" && config.EMLy.UpdateCheckEnabled == "true" {
log.Println("Performing automatic update check...")
status, err := a.CheckForUpdates()
if err != nil {
log.Printf("Auto-update check failed: %v", err)
return
}
// Emit event if update is available
if status.UpdateAvailable {
log.Printf("Update available: %s -> %s", status.CurrentVersion, status.AvailableVersion)
runtime.EventsEmit(ctx, "update:available", status)
} else {
log.Println("No updates available")
}
}
}()
}
}