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 (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -215,10 +214,13 @@ func rmEmptyStrings(s []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create pacman database archive based on provided package metadata structs.
|
// Create pacman database archive based on provided package metadata structs.
|
||||||
func CreatePacmanDb(entries map[string][]byte) ([]byte, error) {
|
func CreatePacmanDb(entries map[string][]byte) (io.ReadSeeker, error) {
|
||||||
var out bytes.Buffer
|
out, err := pkg_module.NewHashedBuffer()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
gw := gzip.NewWriter(&out)
|
gw := gzip.NewWriter(out)
|
||||||
tw := tar.NewWriter(gw)
|
tw := tar.NewWriter(gw)
|
||||||
|
|
||||||
for name, content := range entries {
|
for name, content := range entries {
|
||||||
@ -244,5 +246,5 @@ func CreatePacmanDb(entries map[string][]byte) ([]byte, error) {
|
|||||||
tw.Close()
|
tw.Close()
|
||||||
gw.Close()
|
gw.Close()
|
||||||
|
|
||||||
return out.Bytes(), nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
package arch
|
package arch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -160,7 +159,7 @@ func Get(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ServeContent(bytes.NewReader(db), &context.ServeHeaderOptions{
|
ctx.ServeContent(db, &context.ServeHeaderOptions{
|
||||||
Filename: file,
|
Filename: file,
|
||||||
})
|
})
|
||||||
return
|
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
|
// requested combination of architecture and distribution. When/If the first
|
||||||
// compatible version is found, related desc file will be loaded from database
|
// compatible version is found, related desc file will be loaded from database
|
||||||
// and added to resulting .db.tar.gz archive.
|
// 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)
|
pkgs, err := pkg_model.GetPackagesByType(ctx, ctx.Package.Owner.ID, pkg_model.TypeArch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user