From 8b44d510eb08eb15ba379650a37910b8abe3b3fd Mon Sep 17 00:00:00 2001 From: zuevav Date: Thu, 24 Sep 2026 22:19:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5:=20=D0=BE=D1=82=D0=BA=D0=B0=D0=B7=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20=D0=B2=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20(?= =?UTF-8?q?=D1=81=D0=BD=D1=8F=D1=82=20=D1=81=20=D0=BB=D0=B8=D1=86=D0=B5?= =?UTF-8?q?=D0=BD=D0=B7=D0=B8=D0=B8,=20bj=20=D0=BF=D0=BE=D0=BC=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D1=81=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2)=20=E2=80=94=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D1=83=D0=BB=D1=8C=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=D1=81=D1=8F,=20=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D1=81=D1=82=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=81=D1=8F,=20=D0=BB=D0=B8=D1=86=D0=B5=D0=BD=D0=B7?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B4=D0=BB=D0=B5=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D1=80=D0=B0=D0=B7=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi --- internal/lkgateway/updater.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/lkgateway/updater.go b/internal/lkgateway/updater.go index c9e8f63..af16a59 100644 --- a/internal/lkgateway/updater.go +++ b/internal/lkgateway/updater.go @@ -279,15 +279,28 @@ func (u *Updater) applyUpdate(ctx context.Context, names []string) (string, erro progressNote(strings.TrimPrefix(unlicensedNote(off), "; ")) progressStage(2, "Скачивание файлов") stopWatch := progressWatchDir(staging, total) + refused := false for _, c := range selected { + skip := false for _, a := range m.Artifacts { if a.Name == c.Name { if _, err := cl.DownloadArtifact(ctx, a, staging); err != nil { + // Модуль сняли с лицензии, а bj ещё помнит прежний её состав (узнаёт при продлении): + // сервер обновлений файл не отдаёт — пропускаем модуль, остальное ставим. + if !c.Core && c.Feature != "updates" && strings.Contains(err.Error(), "HTTP 403") { + off = append(off, "«"+c.Title+"»") + refused, skip = true, true + _ = os.Remove(filepath.Join(staging, filepath.Base(a.File))) + continue + } stopWatch() return "", fmt.Errorf("скачивание %s: %w", c.Name, err) } } } + if skip { + continue + } req.Names = append(req.Names, c.Name) if c.New { req.New = append(req.New, c.Name) @@ -295,6 +308,19 @@ func (u *Updater) applyUpdate(ctx context.Context, names []string) (string, erro list = append(list, c.Name+" "+c.Available) } stopWatch() + if refused { + // состав лицензии устарел — обновляем сразу, чтобы разделы снятых модулей пропали + lctx, lcancel := context.WithTimeout(ctx, 30*time.Second) + if err := LicenseRenew(lctx, u.rc); err != nil { + log.Printf("lk-gateway: продление лицензии после отказа в модуле: %v", err) + } + lcancel() + progressNote(strings.TrimPrefix(unlicensedNote(off), "; ")) + if len(req.Names) == 0 { + _ = os.RemoveAll(staging) + return "обновлять нечего: компоненты лицензии актуальны (релиз " + m.Version + ")" + unlicensedNote(off), nil + } + } rb, _ := json.Marshal(req) if err := os.WriteFile(filepath.Join(staging, "request.json"), rb, 0o640); err != nil { return "", err