From 784b4f9304692c0c02469b1e6b11c690f68cb62e Mon Sep 17 00:00:00 2001 From: Danila Fominykh Date: Mon, 2 Oct 2023 22:00:44 -0300 Subject: [PATCH] refactoring in metadata module, pacman database creation function --- modules/packages/arch/metadata.go | 38 +++++++++++++++---------------- services/packages/arch/service.go | 15 ++++-------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/modules/packages/arch/metadata.go b/modules/packages/arch/metadata.go index 970008686b..ce873f867b 100644 --- a/modules/packages/arch/metadata.go +++ b/modules/packages/arch/metadata.go @@ -166,25 +166,25 @@ func (m *DbDesc) String() string { Key string Value string }{ - {Key: "FILENAME", Value: m.Filename}, - {Key: "NAME", Value: m.Name}, - {Key: "BASE", Value: m.Base}, - {Key: "VERSION", Value: m.Version}, - {Key: "DESC", Value: m.Description}, - {Key: "CSIZE", Value: fmt.Sprintf("%d", m.CompressedSize)}, - {Key: "ISIZE", Value: fmt.Sprintf("%d", m.InstalledSize)}, - {Key: "MD5SUM", Value: m.MD5}, - {Key: "SHA256SUM", Value: m.SHA256}, - {Key: "URL", Value: m.URL}, - {Key: "LICENSE", Value: strings.Join(m.License, "\n")}, - {Key: "ARCH", Value: strings.Join(m.Arch, "\n")}, - {Key: "BUILDDATE", Value: fmt.Sprintf("%d", m.BuildDate)}, - {Key: "PACKAGER", Value: m.Packager}, - {Key: "PROVIDES", Value: strings.Join(m.Provides, "\n")}, - {Key: "DEPENDS", Value: strings.Join(m.Depends, "\n")}, - {Key: "OPTDEPENDS", Value: strings.Join(m.OptDepends, "\n")}, - {Key: "MAKEDEPENDS", Value: strings.Join(m.MakeDepends, "\n")}, - {Key: "CHECKDEPENDS", Value: strings.Join(m.CheckDepends, "\n")}, + {"FILENAME", m.Filename}, + {"NAME", m.Name}, + {"BASE", m.Base}, + {"VERSION", m.Version}, + {"DESC", m.Description}, + {"CSIZE", fmt.Sprintf("%d", m.CompressedSize)}, + {"ISIZE", fmt.Sprintf("%d", m.InstalledSize)}, + {"MD5SUM", m.MD5}, + {"SHA256SUM", m.SHA256}, + {"URL", m.URL}, + {"LICENSE", strings.Join(m.License, "\n")}, + {"ARCH", strings.Join(m.Arch, "\n")}, + {"BUILDDATE", fmt.Sprintf("%d", m.BuildDate)}, + {"PACKAGER", m.Packager}, + {"PROVIDES", strings.Join(m.Provides, "\n")}, + {"DEPENDS", strings.Join(m.Depends, "\n")}, + {"OPTDEPENDS", strings.Join(m.OptDepends, "\n")}, + {"MAKEDEPENDS", strings.Join(m.MakeDepends, "\n")}, + {"CHECKDEPENDS", strings.Join(m.CheckDepends, "\n")}, } var result string diff --git a/services/packages/arch/service.go b/services/packages/arch/service.go index 327b12f9c9..7f8f9c07cc 100644 --- a/services/packages/arch/service.go +++ b/services/packages/arch/service.go @@ -81,8 +81,8 @@ func getPackageFile(ctx *context.Context, distro, file string) (*pkg_model.Packa // Finds all arch packages in user/organization scope, each package version // starting from latest in descending order is checked to be compatible with // requested combination of architecture and distribution. When/If the first -// compatible version is found, related desc file will be loaded from database -// and added to resulting .db.tar.gz archive. +// compatible version is found, related desc file will be loaded from package +// properties and added to resulting .db.tar.gz archive. func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSeeker, error) { pkgs, err := pkg_model.GetPackagesByType(ctx, ctx.Package.Owner.ID, pkg_model.TypeArch) if err != nil { @@ -120,19 +120,12 @@ func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (io.ReadSe return nil, err } - var descvalue string for _, pp := range pps { if pp.Name == "desc" { - descvalue = pp.Value + entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(pp.Value) + break } } - - if descvalue == "" { - continue - } - - entries[pkg.Name+"-"+ver.Version+"/desc"] = []byte(descvalue) - break } }