Skip to content

Commit 9e49270

Browse files
KN4CK3Rlunnytechknowlogick
authored
Fix condition for is_internal (#22095) (#22132)
Backport of #22095 I changed it to a static condition because it needs a new version of xorm which is only available in 1.19. This change is valid because `SearchLatestVersions` is never called to list internal versions and there will no change to this behaviour in <1.19. Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 194b780 commit 9e49270

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: models/packages/package_version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func SearchLatestVersions(ctx context.Context, opts *PackageSearchOptions) ([]*P
305305

306306
sess := db.GetEngine(ctx).
307307
Table("package_version").
308-
Join("LEFT", "package_version pv2", "package_version.package_id = pv2.package_id AND (package_version.created_unix < pv2.created_unix OR (package_version.created_unix = pv2.created_unix AND package_version.id < pv2.id))").
308+
Join("LEFT", "package_version pv2", "package_version.package_id = pv2.package_id AND pv2.is_internal = ? AND (package_version.created_unix < pv2.created_unix OR (package_version.created_unix = pv2.created_unix AND package_version.id < pv2.id))", false).
309309
Join("INNER", "package", "package.id = package_version.package_id").
310310
Where(cond)
311311

Diff for: routers/api/packages/npm/npm.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,9 @@ func setPackageTag(tag string, pv *packages_model.PackageVersion, deleteOnly boo
402402

403403
func PackageSearch(ctx *context.Context) {
404404
pvs, total, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
405-
OwnerID: ctx.Package.Owner.ID,
406-
Type: packages_model.TypeNpm,
405+
OwnerID: ctx.Package.Owner.ID,
406+
Type: packages_model.TypeNpm,
407+
IsInternal: util.OptionalBoolFalse,
407408
Name: packages_model.SearchValue{
408409
ExactMatch: false,
409410
Value: ctx.FormTrim("text"),

0 commit comments

Comments
 (0)