moved package properties to constants in metadata module

This commit is contained in:
Danila Fominykh 2023-11-01 15:24:40 -03:00
parent 42587dde80
commit d6a05c30d2
No known key found for this signature in database
GPG Key ID: FC04D07F75B663FC
3 changed files with 9 additions and 4 deletions

View File

@ -23,6 +23,11 @@ import (
"github.com/mholt/archiver/v3" "github.com/mholt/archiver/v3"
) )
const (
PropertyDescription = "arch.description"
PropertySignature = "arch.signature"
)
var ( var (
// https://man.archlinux.org/man/PKGBUILD.5 // https://man.archlinux.org/man/PKGBUILD.5
reName = regexp.MustCompile(`^[a-zA-Z0-9@._+-]+$`) reName = regexp.MustCompile(`^[a-zA-Z0-9@._+-]+$`)

View File

@ -44,7 +44,7 @@ func GetPackageSignature(ctx *context.Context, distro, file string) (*bytes.Read
} }
for _, pp := range proprs { for _, pp := range proprs {
if pp.Name == "sign" { if pp.Name == arch_module.PropertySignature {
b, err := hex.DecodeString(pp.Value) b, err := hex.DecodeString(pp.Value)
if err != nil { if err != nil {
return nil, err return nil, err
@ -116,7 +116,7 @@ func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) (*bytes.Bu
} }
pps, err := packages_model.GetPropertiesByName( pps, err := packages_model.GetPropertiesByName(
ctx, packages_model.PropertyTypeFile, pf.ID, "desc", ctx, packages_model.PropertyTypeFile, pf.ID, arch_module.PropertyDescription,
) )
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -37,14 +37,14 @@ func UploadArchPackage(ctx *context.Context, upload io.Reader, filename, distro,
} }
properties := map[string]string{ properties := map[string]string{
"desc": p.Desc(), arch_module.PropertyDescription: p.Desc(),
} }
if sign != "" { if sign != "" {
_, err := hex.DecodeString(sign) _, err := hex.DecodeString(sign)
if err != nil { if err != nil {
return true, nil, errors.New("unable to decode package signature") return true, nil, errors.New("unable to decode package signature")
} }
properties["sign"] = sign properties[arch_module.PropertySignature] = sign
} }
ver, _, err := packages_service.CreatePackageOrAddFileToExisting( ver, _, err := packages_service.CreatePackageOrAddFileToExisting(