summaryrefslogtreecommitdiffstats
path: root/models/packages
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-04-04 10:14:46 +0200
committerGitHub <noreply@github.com>2023-04-04 16:14:46 +0800
commitd93f3222a5eb88fbc0f192c3bf3a0ebfd7ccc6c9 (patch)
tree7141332c53ceab2c5bb9f273c640c728a02137e0 /models/packages
parent62a9052075e6042be7b4af9502ba396871e557d3 (diff)
downloadgitea-d93f3222a5eb88fbc0f192c3bf3a0ebfd7ccc6c9.tar.gz
gitea-d93f3222a5eb88fbc0f192c3bf3a0ebfd7ccc6c9.zip
Use ghost user if package creator does not exist (#23822)
Fixes #23818
Diffstat (limited to 'models/packages')
-rw-r--r--models/packages/descriptor.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/models/packages/descriptor.go b/models/packages/descriptor.go
index 06699b5d57..974c5b2c36 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 {