feat: Настройки › Автообновление - clients compare their version with the server's every N and update themselves; the server looks at GitLab every N and, when a newer release is out, offers it to an administrator at login (after the PIN) with «Обновить» and «Отказаться»; the words of a made picture's result are the model's only

This commit is contained in:
redtea committed 2026-10-18 12:33:24 +03:00
1 parent 916a49958b
commit 3d2f886f04
22 files changed
+1074 -7

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
package proto
import (
"strconv"
"strings"
)
// versionParts reads "0.2.5" (a leading v and a "-suffix" are allowed) as
// numbers; ok is false for anything that is not a dotted number.
func versionParts(v string) (parts []int, ok bool) {
v = strings.TrimPrefix(strings.TrimSpace(v), "v")
if i := strings.IndexAny(v, "-+"); i >= 0 {
v = v[:i]
}
if v == "" {
return nil, false
}
for _, p := range strings.Split(v, ".") {
n, err := strconv.Atoi(p)
if err != nil || n < 0 {
return nil, false
}
parts = append(parts, n)
}
return parts, true
}
// VersionNewer reports whether version a is higher than b. Anything that is
// not a dotted number (a build named "dev", an empty string) is never newer
// and never older - so a program is never "updated" down, or from a guess.
func VersionNewer(a, b string) bool {
pa, okA := versionParts(a)
pb, okB := versionParts(b)
if !okA || !okB {
return false
}
for i := 0; i < len(pa) || i < len(pb); i++ {
var x, y int
if i < len(pa) {
x = pa[i]
}
if i < len(pb) {
y = pb[i]
}
if x != y {
return x > y
}
}
return false
}