Ariver
2026-06-03 b94a79dc7c9cfcdf72605289d0b89e85238c7d02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package services
 
import (
    "voicesnap/internal/updater"
)
 
// UpdaterService provides update checking and downloading to the frontend.
type UpdaterService struct {
    currentVersion string
}
 
func NewUpdaterService(version string) *UpdaterService {
    return &UpdaterService{currentVersion: version}
}
 
// CheckForUpdate checks if a newer version is available.
// Returns version info if an update is available, nil otherwise.
func (s *UpdaterService) CheckForUpdate() (*updater.VersionInfo, error) {
    info, err := updater.CheckForUpdate()
    if err != nil {
        return nil, err
    }
 
    if updater.IsNewer(info.Version, s.currentVersion) {
        return info, nil
    }
 
    return nil, nil
}
 
// GetCurrentVersion returns the current application version.
func (s *UpdaterService) GetCurrentVersion() string {
    return s.currentVersion
}
 
// PerformUpdate downloads and applies the update.
func (s *UpdaterService) PerformUpdate(downloadURL string) error {
    return updater.PerformUpdate(downloadURL, nil)
}