Package registry changes (#19305)
* removed debug logs * fixed SELECT * removed unneeded error type * use common SearchVersions method * remove empty container upload versions * return err
This commit is contained in:
parent
8ddcd37f13
commit
5e242e021b
17 changed files with 185 additions and 150 deletions
|
@ -63,8 +63,8 @@ func SearchPackages(ctx *context.Context) {
|
|||
|
||||
opts := &packages_model.PackageSearchOptions{
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: string(packages_model.TypeComposer),
|
||||
QueryName: ctx.FormTrim("q"),
|
||||
Type: packages_model.TypeComposer,
|
||||
Name: packages_model.SearchValue{Value: ctx.FormTrim("q")},
|
||||
Paginator: &paginator,
|
||||
}
|
||||
if ctx.FormTrim("type") != "" {
|
||||
|
|
|
@ -256,7 +256,12 @@ func setPackageTag(tag string, pv *packages_model.PackageVersion, deleteOnly boo
|
|||
}
|
||||
defer committer.Close()
|
||||
|
||||
pvs, err := packages_model.FindVersionsByPropertyNameAndValue(ctx, pv.PackageID, npm_module.TagProperty, tag)
|
||||
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
PackageID: pv.PackageID,
|
||||
Properties: map[string]string{
|
||||
npm_module.TagProperty: tag,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ func ServiceIndex(ctx *context.Context) {
|
|||
// SearchService https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-for-packages
|
||||
func SearchService(ctx *context.Context) {
|
||||
pvs, count, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: string(packages_model.TypeNuGet),
|
||||
QueryName: ctx.FormTrim("q"),
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: packages_model.TypeNuGet,
|
||||
Name: packages_model.SearchValue{Value: ctx.FormTrim("q")},
|
||||
Paginator: db.NewAbsoluteListOptions(
|
||||
ctx.FormInt("skip"),
|
||||
ctx.FormInt("take"),
|
||||
|
|
|
@ -41,7 +41,7 @@ func EnumeratePackages(ctx *context.Context) {
|
|||
func EnumeratePackagesLatest(ctx *context.Context) {
|
||||
pvs, _, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: string(packages_model.TypeRubyGems),
|
||||
Type: packages_model.TypeRubyGems,
|
||||
})
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
|
@ -96,7 +96,7 @@ func ServePackageSpecification(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
pvs, err := packages_model.GetVersionsByFilename(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, filename[:len(filename)-10]+"gem")
|
||||
pvs, err := getVersionsByFilename(ctx, filename[:len(filename)-10]+"gem")
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
return
|
||||
|
@ -158,7 +158,7 @@ func ServePackageSpecification(ctx *context.Context) {
|
|||
func DownloadPackageFile(ctx *context.Context) {
|
||||
filename := ctx.Params("filename")
|
||||
|
||||
pvs, err := packages_model.GetVersionsByFilename(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, filename)
|
||||
pvs, err := getVersionsByFilename(ctx, filename)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
return
|
||||
|
@ -283,3 +283,12 @@ func DeletePackage(ctx *context.Context) {
|
|||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
}
|
||||
}
|
||||
|
||||
func getVersionsByFilename(ctx *context.Context, filename string) ([]*packages_model.PackageVersion, error) {
|
||||
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: packages_model.TypeRubyGems,
|
||||
HasFileWithName: filename,
|
||||
})
|
||||
return pvs, err
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ func ListPackages(ctx *context.APIContext) {
|
|||
|
||||
pvs, count, err := packages.SearchVersions(ctx, &packages.PackageSearchOptions{
|
||||
OwnerID: ctx.Package.Owner.ID,
|
||||
Type: packageType,
|
||||
QueryName: query,
|
||||
Type: packages.Type(packageType),
|
||||
Name: packages.SearchValue{Value: query},
|
||||
Paginator: &listOptions,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -31,9 +31,9 @@ func Packages(ctx *context.Context) {
|
|||
sort := ctx.FormTrim("sort")
|
||||
|
||||
pvs, total, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
QueryName: query,
|
||||
Type: packageType,
|
||||
Sort: sort,
|
||||
Type: packages_model.Type(packageType),
|
||||
Name: packages_model.SearchValue{Value: query},
|
||||
Sort: sort,
|
||||
Paginator: &db.ListOptions{
|
||||
PageSize: setting.UI.PackagesPagingNum,
|
||||
Page: page,
|
||||
|
|
|
@ -32,10 +32,10 @@ func Packages(ctx *context.Context) {
|
|||
PageSize: setting.UI.PackagesPagingNum,
|
||||
Page: page,
|
||||
},
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
QueryName: query,
|
||||
Type: packageType,
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Type: packages.Type(packageType),
|
||||
Name: packages.SearchValue{Value: query},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchLatestVersions", err)
|
||||
|
|
|
@ -43,9 +43,9 @@ func ListPackages(ctx *context.Context) {
|
|||
PageSize: setting.UI.PackagesPagingNum,
|
||||
Page: page,
|
||||
},
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
Type: packageType,
|
||||
QueryName: query,
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
Type: packages_model.Type(packageType),
|
||||
Name: packages_model.SearchValue{Value: query},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchLatestVersions", err)
|
||||
|
@ -219,9 +219,12 @@ func ListPackageVersions(ctx *context.Context) {
|
|||
}
|
||||
default:
|
||||
pvs, total, err = packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
|
||||
Paginator: pagination,
|
||||
PackageID: p.ID,
|
||||
QueryVersion: query,
|
||||
Paginator: pagination,
|
||||
PackageID: p.ID,
|
||||
Version: packages_model.SearchValue{
|
||||
ExactMatch: false,
|
||||
Value: query,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchVersions", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue