fix cache download

pull/31037/head
dragon 2 months ago
parent 317ea7f5cd
commit fbe09b2e77
  1. 14
      routers/api/packages/arch/arch.go
  2. 16
      services/packages/arch/repository.go

@ -171,7 +171,7 @@ func GetPackageOrDB(ctx *context.Context) {
)
if archPkgOrSig.MatchString(file) {
pkg, err := arch_service.GetPackageFile(ctx, group, file, ctx.Package.Owner.ID)
pkg, u, pf, err := arch_service.GetPackageFile(ctx, group, file, ctx.Package.Owner.ID)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@ -180,15 +180,12 @@ func GetPackageOrDB(ctx *context.Context) {
}
return
}
ctx.ServeContent(pkg, &context.ServeHeaderOptions{
Filename: file,
})
helper.ServePackageFile(ctx, pkg, u, pf)
return
}
if archDBOrSig.MatchString(file) {
pkg, err := arch_service.GetPackageDBFile(ctx, group, arch, ctx.Package.Owner.ID,
pkg, u, pf, err := arch_service.GetPackageDBFile(ctx, group, arch, ctx.Package.Owner.ID,
strings.HasSuffix(file, ".sig"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@ -198,9 +195,8 @@ func GetPackageOrDB(ctx *context.Context) {
}
return
}
ctx.ServeContent(pkg, &context.ServeHeaderOptions{
Filename: file,
})
helper.ServePackageFile(ctx, pkg, u, pf)
return
}

@ -245,14 +245,13 @@ func createDB(ctx context.Context, ownerID int64, group, arch string) (*packages
// GetPackageFile Get data related to provided filename and distribution, for package files
// update download counter.
func GetPackageFile(ctx context.Context, group, file string, ownerID int64) (io.ReadSeekCloser, error) {
func GetPackageFile(ctx context.Context, group, file string, ownerID int64) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error) {
pf, err := getPackageFile(ctx, group, file, ownerID)
if err != nil {
return nil, err
return nil, nil, nil, err
}
filestream, _, _, err := packages_service.GetPackageFileStream(ctx, pf)
return filestream, err
return packages_service.GetPackageFileStream(ctx, pf)
}
// Ejects parameters required to get package file property from file name.
@ -275,10 +274,10 @@ func getPackageFile(ctx context.Context, group, file string, ownerID int64) (*pa
return pkgfile, nil
}
func GetPackageDBFile(ctx context.Context, group, arch string, ownerID int64, signFile bool) (io.ReadSeekCloser, error) {
func GetPackageDBFile(ctx context.Context, group, arch string, ownerID int64, signFile bool) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error) {
pv, err := GetOrCreateRepositoryVersion(ctx, ownerID)
if err != nil {
return nil, err
return nil, nil, nil, err
}
fileName := fmt.Sprintf("%s.db", arch)
if signFile {
@ -286,10 +285,9 @@ func GetPackageDBFile(ctx context.Context, group, arch string, ownerID int64, si
}
file, err := packages_model.GetFileForVersionByName(ctx, pv.ID, fileName, group)
if err != nil {
return nil, err
return nil, nil, nil, err
}
filestream, _, _, err := packages_service.GetPackageFileStream(ctx, file)
return filestream, err
return packages_service.GetPackageFileStream(ctx, file)
}
// GetOrCreateKeyPair gets or creates the PGP keys used to sign repository metadata files

Loading…
Cancel
Save