Skip to content

Commit

Permalink
Fix/fix download fail (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH authored Oct 10, 2023
1 parent ddaaa67 commit 545dc27
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions route/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 49 in route/installer.go

View workflow job for this annotation

GitHub Actions / goreleaser

no new variables on left side of :=

Check failure on line 49 in route/installer.go

View workflow job for this annotation

GitHub Actions / build

no new variables on left side of :=

Check failure on line 49 in route/installer.go

View workflow job for this annotation

GitHub Actions / goreleaser

no new variables on left side of :=
release, err := service.InstallerService.GetRelease(http_trigger_context, tag)

Check failure on line 50 in route/installer.go

View workflow job for this annotation

GitHub Actions / goreleaser

no new variables on left side of :=

Check failure on line 50 in route/installer.go

View workflow job for this annotation

GitHub Actions / build

no new variables on left side of :=

Check failure on line 50 in route/installer.go

View workflow job for this annotation

GitHub Actions / goreleaser

no new variables on left side of :=

status, _ := service.GetStatus()
if status.Status == codegen.Downloading {
Expand All @@ -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
Expand Down

0 comments on commit 545dc27

Please sign in to comment.