@Summary List Mirror Packages @Description **Get a list of packages from a mirror** @Tags Mirrors @Param name path string true "mirror name" @Param q query string false "search query" @Param format query string false "format: `details` for more detailed information" @Produce json @Success 200 {array
(c *gin.Context)
| 305 | // @Failure 500 {object} Error "Internal Error" |
| 306 | // @Router /api/mirrors/{name}/packages [get] |
| 307 | func apiMirrorsPackages(c *gin.Context) { |
| 308 | collectionFactory := context.NewCollectionFactory() |
| 309 | collection := collectionFactory.RemoteRepoCollection() |
| 310 | |
| 311 | name := c.Params.ByName("name") |
| 312 | repo, err := collection.ByName(name) |
| 313 | if err != nil { |
| 314 | AbortWithJSONError(c, 404, fmt.Errorf("unable to show: %s", err)) |
| 315 | return |
| 316 | } |
| 317 | |
| 318 | err = collection.LoadComplete(repo) |
| 319 | if err != nil { |
| 320 | AbortWithJSONError(c, 500, fmt.Errorf("unable to show: %s", err)) |
| 321 | } |
| 322 | |
| 323 | if repo.LastDownloadDate.IsZero() { |
| 324 | AbortWithJSONError(c, 404, fmt.Errorf("unable to show package list, mirror hasn't been downloaded yet")) |
| 325 | return |
| 326 | } |
| 327 | |
| 328 | reflist := repo.RefList() |
| 329 | result := []*deb.Package{} |
| 330 | |
| 331 | list, err := deb.NewPackageListFromRefList(reflist, collectionFactory.PackageCollection(), nil) |
| 332 | if err != nil { |
| 333 | AbortWithJSONError(c, 404, err) |
| 334 | return |
| 335 | } |
| 336 | |
| 337 | queryS := c.Request.URL.Query().Get("q") |
| 338 | if queryS != "" { |
| 339 | q, err := query.Parse(c.Request.URL.Query().Get("q")) |
| 340 | if err != nil { |
| 341 | AbortWithJSONError(c, 400, err) |
| 342 | return |
| 343 | } |
| 344 | |
| 345 | withDeps := c.Request.URL.Query().Get("withDeps") == "1" |
| 346 | architecturesList := []string{} |
| 347 | |
| 348 | if withDeps { |
| 349 | if len(context.ArchitecturesList()) > 0 { |
| 350 | architecturesList = context.ArchitecturesList() |
| 351 | } else { |
| 352 | architecturesList = list.Architectures(false) |
| 353 | } |
| 354 | |
| 355 | sort.Strings(architecturesList) |
| 356 | |
| 357 | if len(architecturesList) == 0 { |
| 358 | AbortWithJSONError(c, 400, fmt.Errorf("unable to determine list of architectures, please specify explicitly")) |
| 359 | return |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | list.PrepareIndex() |
| 364 |
nothing calls this directly
no test coverage detected