Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 19:26:09 +01:00

Use ghost user if package creator does not exist (#23822)

Fixes #23818
This commit is contained in:
KN4CK3R 2023-04-04 10:14:46 +02:00 committed by GitHub
parent 62a9052075
commit d93f3222a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ package packages
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net/url" "net/url"
@ -26,6 +27,7 @@ import (
"code.gitea.io/gitea/modules/packages/rubygems" "code.gitea.io/gitea/modules/packages/rubygems"
"code.gitea.io/gitea/modules/packages/swift" "code.gitea.io/gitea/modules/packages/swift"
"code.gitea.io/gitea/modules/packages/vagrant" "code.gitea.io/gitea/modules/packages/vagrant"
"code.gitea.io/gitea/modules/util"
"github.com/hashicorp/go-version" "github.com/hashicorp/go-version"
) )
@ -99,8 +101,12 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc
} }
creator, err := user_model.GetUserByID(ctx, pv.CreatorID) creator, err := user_model.GetUserByID(ctx, pv.CreatorID)
if err != nil { if err != nil {
if errors.Is(err, util.ErrNotExist) {
creator = user_model.NewGhostUser()
} else {
return nil, err return nil, err
} }
}
var semVer *version.Version var semVer *version.Version
if p.SemverCompatible { if p.SemverCompatible {
semVer, err = version.NewVersion(pv.Version) semVer, err = version.NewVersion(pv.Version)