mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
replaced bytes.Buffer with packages.HashedBuffer to return working io.ReadSeeker implementation
This commit is contained in:
parent
946d8cc9ea
commit
4656b3b958
@ -6,7 +6,6 @@ package arch
|
||||
import (
|
||||
"archive/tar"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@ -215,10 +214,13 @@ func rmEmptyStrings(s []string) []string {
|
||||
}
|
||||
|
||||
// Create pacman database archive based on provided package metadata structs.
|
||||
func CreatePacmanDb(entries map[string][]byte) ([]byte, error) {
|
||||
var out bytes.Buffer
|
||||
func CreatePacmanDb(entries map[string][]byte) (io.ReadSeeker, error) {
|
||||
out, err := pkg_module.NewHashedBuffer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gw := gzip.NewWriter(&out)
|
||||
gw := gzip.NewWriter(out)
|
||||
tw := tar.NewWriter(gw)
|
||||
|
||||
for name, content := range entries {
|
||||
@ -244,5 +246,5 @@ func CreatePacmanDb(entries map[string][]byte) ([]byte, error) {
|
||||
tw.Close()
|
||||
gw.Close()
|
||||
|
||||
return out.Bytes(), nil
|
||||
return out, nil
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
package arch
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -160,7 +159,7 @@ func Get(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.ServeContent(bytes.NewReader(db), &context.ServeHeaderOptions{
|
||||
ctx.ServeContent(db, &context.ServeHeaderOptions{
|
||||
Filename: file,
|
||||
})
|
||||
return
|
||||
|
@ -77,7 +77,7 @@ func RepoConnect(ctx *context.Context, owner, repo string, pkgid int64) error {
|
||||
// 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.
|
||||
func CreatePacmanDb(ctx *context.Context, owner, arch, distro string) ([]byte, error) {
|
||||
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 {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user