Fix old pacakge versions hanging around
This commit is contained in:
parent
6c31af0166
commit
c2d3850a33
@ -129,6 +129,15 @@ func (r *Repository) SavePackages(pkgs *haxmap.Map[string, domain.SourcePackage]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Repository) DropPackages() error {
|
||||
tx := r.db.Where("1 = 1").Delete(&domain.SourcePackageDTO{})
|
||||
if tx.Error != nil {
|
||||
return tx.Error
|
||||
}
|
||||
tx = r.db.Where("1 = 1").Delete(&domain.PackageInfo{})
|
||||
return tx.Error
|
||||
}
|
||||
|
||||
func (r *Repository) UpdateLastUpdateTime(time time.Time) error {
|
||||
val := &domain.TimeContainer{
|
||||
Time: time,
|
||||
|
17
handlers/packages/package.go
Normal file
17
handlers/packages/package.go
Normal file
@ -0,0 +1,17 @@
|
||||
package handlers_packages
|
||||
|
||||
import (
|
||||
"brunel/packages"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Package(c *fiber.Ctx) error {
|
||||
pkgName := c.Params("package")
|
||||
packs := packages.GetPackages()
|
||||
pack, ok := packs.Get(pkgName)
|
||||
if !ok {
|
||||
return c.Status(fiber.StatusNotFound).SendString("Package not found")
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(pack)
|
||||
}
|
@ -92,6 +92,10 @@ func ProcessPackages() error {
|
||||
|
||||
LastUpdateTime = time.Now()
|
||||
helpers.ReloadCache()
|
||||
err = helpers.DBInst.DropPackages()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = SaveToDb()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -92,6 +92,7 @@ func runServer(ctx context.Context) error {
|
||||
|
||||
server.Get("/api/counts", handlers_packages.Counts)
|
||||
server.Get("/api/packages", handlers_packages.Packages)
|
||||
server.Get("/api/package/:package", handlers_packages.Package)
|
||||
server.Get("/api/queue", handlers_build.Queue)
|
||||
server.Get("/api/errored", handlers_build.Errored)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user