diff --git a/route/installer.go b/route/installer.go index ef9b6da..e166c6d 100644 --- a/route/installer.go +++ b/route/installer.go @@ -24,8 +24,30 @@ func (a *api) GetStatus(ctx echo.Context) error { } func (a *api) GetRelease(ctx echo.Context, params codegen.GetReleaseParams) error { + // TODO 考虑一下这个packageStatus的问题 + // go service.UpdateStatusWithMessage(service.FetchUpdateBegin, "主动触发的获取信息") + tag := service.GetReleaseBranch(sysRoot) + if params.Version != nil && *params.Version != "latest" { + tag = *params.Version + } + + http_trigger_context := context.WithValue(ctx.Request().Context(), types.Trigger, types.HTTP_REQUEST) release, err := service.InstallerService.GetRelease(http_trigger_context, tag) + if err != nil { + message := err.Error() + if err == service.ErrReleaseNotFound { + return ctx.JSON(http.StatusNotFound, &codegen.ResponseNotFound{ + Message: &message, + }) + } + return ctx.JSON(http.StatusInternalServerError, &codegen.ResponseInternalServerError{ + Message: &message, + }) + } + + http_trigger_context := context.WithValue(ctx.Request().Context(), types.Trigger, types.HTTP_REQUEST) + release, err := service.InstallerService.GetRelease(http_trigger_context, tag) status, _ := service.GetStatus() if status.Status == codegen.Downloading { @@ -40,14 +62,7 @@ func (a *api) GetRelease(ctx echo.Context, params codegen.GetReleaseParams) erro Upgradable: utils.Ptr(false), }) } - - // TODO 考虑一下这个packageStatus的问题 - // go service.UpdateStatusWithMessage(service.FetchUpdateBegin, "主动触发的获取信息") - tag := service.GetReleaseBranch(sysRoot) - - if params.Version != nil && *params.Version != "latest" { - tag = *params.Version - } + // 无其它东西在干扰的情况 // 这里就拿导致拿两次release了 // 这里不能用request的context,不然会cancel