diff options
author | dragon <ExplodingFKL@gmail.com> | 2024-12-06 07:51:49 +0100 |
---|---|---|
committer | dragon <ExplodingFKL@gmail.com> | 2024-12-09 04:34:50 +0100 |
commit | 37a300b105a0178f28693abcb5466e808f3f9627 (patch) | |
tree | f8018561bab3e53eb8ab01e6adc7850e51d9d4cf /services | |
parent | Merge pull request 'Update dependency katex to v0.16.14 (forgejo)' (#6205) fr... (diff) | |
download | forgejo-37a300b105a0178f28693abcb5466e808f3f9627.tar.xz forgejo-37a300b105a0178f28693abcb5466e808f3f9627.zip |
Add support for indexing arch files
Diffstat (limited to 'services')
-rw-r--r-- | services/packages/arch/repository.go | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/services/packages/arch/repository.go b/services/packages/arch/repository.go index 763a0a2102..e681f24561 100644 --- a/services/packages/arch/repository.go +++ b/services/packages/arch/repository.go @@ -225,22 +225,44 @@ func createDB(ctx context.Context, ownerID int64, group, arch string) (*packages if err != nil { return nil, err } - if len(pps) >= 1 { - meta := []byte(pps[0].Value) + if len(pps) == 0 { + continue + } + pkgDesc := []byte(pps[0].Value) + header := &tar.Header{ + Name: pkg.Name + "-" + ver.Version + "/desc", + Size: int64(len(pkgDesc)), + Mode: int64(os.ModePerm), + } + if err = tw.WriteHeader(header); err != nil { + return nil, err + } + if _, err := tw.Write(pkgDesc); err != nil { + return nil, err + } + + pfs, err := packages_model.GetPropertiesByName( + ctx, packages_model.PropertyTypeFile, pf.ID, arch_module.PropertyFiles, + ) + if err != nil { + return nil, err + } + if len(pfs) >= 1 { + pkgFiles := []byte(pfs[0].Value) header := &tar.Header{ - Name: pkg.Name + "-" + ver.Version + "/desc", - Size: int64(len(meta)), + Name: pkg.Name + "-" + ver.Version + "/files", + Size: int64(len(pkgFiles)), Mode: int64(os.ModePerm), } if err = tw.WriteHeader(header); err != nil { return nil, err } - if _, err := tw.Write(meta); err != nil { + if _, err := tw.Write(pkgFiles); err != nil { return nil, err } - count++ - break } + count++ + break } } if count == 0 { |