From c2f6b91414f22ee09cc646bcd590df21575eef5d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Thu, 30 Mar 2023 15:29:17 +0000 Subject: [PATCH] Use ghost user if creator does not exist. --- models/packages/descriptor.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/packages/descriptor.go b/models/packages/descriptor.go index 06699b5d572b2..974c5b2c362a6 100644 --- a/models/packages/descriptor.go +++ b/models/packages/descriptor.go @@ -5,6 +5,7 @@ package packages import ( "context" + "errors" "fmt" "net/url" @@ -26,6 +27,7 @@ import ( "code.gitea.io/gitea/modules/packages/rubygems" "code.gitea.io/gitea/modules/packages/swift" "code.gitea.io/gitea/modules/packages/vagrant" + "code.gitea.io/gitea/modules/util" "github.com/hashicorp/go-version" ) @@ -99,7 +101,11 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc } creator, err := user_model.GetUserByID(ctx, pv.CreatorID) if err != nil { - return nil, err + if errors.Is(err, util.ErrNotExist) { + creator = user_model.NewGhostUser() + } else { + return nil, err + } } var semVer *version.Version if p.SemverCompatible {