Merge branch 'snapshot-api' of https://github.com/lebauce/aptly into lebauce-snapshot-api

Conflicts:
	api/router.go
	system/t12_api/__init__.py
This commit is contained in:
Andrey Smirnov
2015-01-22 21:29:58 +03:00
10 changed files with 768 additions and 78 deletions
+19 -11
View File
@@ -178,6 +178,15 @@ func apiReposPackagesShow(c *gin.Context) {
return
}
list, err := deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
if err != nil {
c.Fail(500, err)
return
}
list.PrepareIndex()
result := []*deb.Package{}
queryS := c.Request.URL.Query().Get("q")
if queryS != "" {
q, err := query.Parse(queryS)
@@ -186,14 +195,6 @@ func apiReposPackagesShow(c *gin.Context) {
return
}
list, err := deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
if err != nil {
c.Fail(500, err)
return
}
list.PrepareIndex()
withDeps := c.Request.URL.Query().Get("withDeps") == "1"
architecturesList := []string{}
@@ -212,16 +213,23 @@ func apiReposPackagesShow(c *gin.Context) {
}
}
result, err := list.Filter([]deb.PackageQuery{q}, withDeps,
list, err = list.Filter([]deb.PackageQuery{q}, withDeps,
nil, context.DependencyOptions(), architecturesList)
if err != nil {
c.Fail(500, err)
return
}
}
c.JSON(200, result.Strings())
if c.Request.URL.Query().Get("format") == "details" {
list.ForEach(func(p *deb.Package) error {
result = append(result, p)
return nil
})
c.JSON(200, result)
} else {
c.JSON(200, repo.RefList().Strings())
c.JSON(200, list.Strings())
}
}