mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
Refactor Filter options into a struct
It was already a lot of options for one method and I am going to add another one in the next commit.
This commit is contained in:
14
api/api.go
14
api/api.go
@@ -227,8 +227,13 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
|
||||
list.PrepareIndex()
|
||||
|
||||
list, err = list.Filter([]deb.PackageQuery{q}, withDeps,
|
||||
nil, context.DependencyOptions(), architecturesList)
|
||||
list, err = list.Filter(deb.FilterOptions{
|
||||
Queries: []deb.PackageQuery{q},
|
||||
WithDependencies: withDeps,
|
||||
Source: nil,
|
||||
DependencyOptions: context.DependencyOptions(),
|
||||
Architectures: architecturesList,
|
||||
})
|
||||
if err != nil {
|
||||
AbortWithJSONError(c, 500, fmt.Errorf("unable to search: %s", err))
|
||||
return
|
||||
@@ -244,8 +249,9 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList, collectionFactory
|
||||
fmt.Println("filter packages by version, query string parse err: ", err)
|
||||
c.AbortWithError(500, fmt.Errorf("unable to parse %s maximum version query string: %s", p.Name, err))
|
||||
} else {
|
||||
tmpList, err := list.Filter([]deb.PackageQuery{versionQ}, false,
|
||||
nil, 0, []string{})
|
||||
tmpList, err := list.Filter(deb.FilterOptions{
|
||||
Queries: []deb.PackageQuery{versionQ},
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
if tmpList.Len() > 0 {
|
||||
|
||||
@@ -306,8 +306,12 @@ func apiMirrorsPackages(c *gin.Context) {
|
||||
|
||||
list.PrepareIndex()
|
||||
|
||||
list, err = list.Filter([]deb.PackageQuery{q}, withDeps,
|
||||
nil, context.DependencyOptions(), architecturesList)
|
||||
list, err = list.Filter(deb.FilterOptions{
|
||||
Queries: []deb.PackageQuery{q},
|
||||
WithDependencies: withDeps,
|
||||
DependencyOptions: context.DependencyOptions(),
|
||||
Architectures: architecturesList,
|
||||
})
|
||||
if err != nil {
|
||||
AbortWithJSONError(c, 500, fmt.Errorf("unable to search: %s", err))
|
||||
}
|
||||
|
||||
@@ -586,7 +586,14 @@ func apiReposCopyPackage(c *gin.Context) {
|
||||
return &task.ProcessReturnValue{Code: http.StatusUnprocessableEntity, Value: nil}, fmt.Errorf("unable to parse query '%s': %s", fileName, err)
|
||||
}
|
||||
|
||||
toProcess, err := srcList.FilterWithProgress(queries, jsonBody.WithDeps, dstList, context.DependencyOptions(), architecturesList, context.Progress())
|
||||
toProcess, err := srcList.Filter(deb.FilterOptions{
|
||||
Queries: queries,
|
||||
WithDependencies: jsonBody.WithDeps,
|
||||
Source: dstList,
|
||||
DependencyOptions: context.DependencyOptions(),
|
||||
Architectures: architecturesList,
|
||||
Progress: context.Progress(),
|
||||
})
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("filter error: %s", err)
|
||||
}
|
||||
|
||||
@@ -636,7 +636,14 @@ func apiSnapshotsPull(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Filter with dependencies as requested
|
||||
destinationPackageList, err := sourcePackageList.FilterWithProgress(queries, !noDeps, toPackageList, context.DependencyOptions(), architecturesList, context.Progress())
|
||||
destinationPackageList, err := sourcePackageList.Filter(deb.FilterOptions{
|
||||
Queries: queries,
|
||||
WithDependencies: !noDeps,
|
||||
Source: toPackageList,
|
||||
DependencyOptions: context.DependencyOptions(),
|
||||
Architectures: architecturesList,
|
||||
Progress: context.Progress(),
|
||||
})
|
||||
if err != nil {
|
||||
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user