summaryrefslogtreecommitdiffstats
path: root/services/packages
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-04-01 01:08:32 +0200
committerGitHub <noreply@github.com>2022-04-01 01:08:32 +0200
commit08d199245ade5f1c4e0898cfe67f3b635a287675 (patch)
treee8f7d47b7e842e33cb7448e321c5af0901f2b360 /services/packages
parent242d71035a8906e2b31360386f8e4861bf4e3da8 (diff)
downloadgitea-08d199245ade5f1c4e0898cfe67f3b635a287675.tar.gz
gitea-08d199245ade5f1c4e0898cfe67f3b635a287675.zip
Fix container download counter (#19287)
* Increment counter on manifest download. * Refactor GetPackageFileStream method.
Diffstat (limited to 'services/packages')
-rw-r--r--services/packages/packages.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/services/packages/packages.go b/services/packages/packages.go
index b26e60c711..7f90f80baf 100644
--- a/services/packages/packages.go
+++ b/services/packages/packages.go
@@ -426,7 +426,7 @@ func GetFileStreamByPackageVersionAndFileID(ctx context.Context, owner *user_mod
return nil, nil, err
}
- return GetPackageFileStream(ctx, pv, pf)
+ return GetPackageFileStream(ctx, pf)
}
// GetFileStreamByPackageVersion returns the content of the specific package file
@@ -436,11 +436,11 @@ func GetFileStreamByPackageVersion(ctx context.Context, pv *packages_model.Packa
return nil, nil, err
}
- return GetPackageFileStream(ctx, pv, pf)
+ return GetPackageFileStream(ctx, pf)
}
// GetPackageFileStream returns the content of the specific package file
-func GetPackageFileStream(ctx context.Context, pv *packages_model.PackageVersion, pf *packages_model.PackageFile) (io.ReadCloser, *packages_model.PackageFile, error) {
+func GetPackageFileStream(ctx context.Context, pf *packages_model.PackageFile) (io.ReadCloser, *packages_model.PackageFile, error) {
pb, err := packages_model.GetBlobByID(ctx, pf.BlobID)
if err != nil {
return nil, nil, err
@@ -449,7 +449,7 @@ func GetPackageFileStream(ctx context.Context, pv *packages_model.PackageVersion
s, err := packages_module.NewContentStore().Get(packages_module.BlobHash256Key(pb.HashSHA256))
if err == nil {
if pf.IsLead {
- if err := packages_model.IncrementDownloadCounter(ctx, pv.ID); err != nil {
+ if err := packages_model.IncrementDownloadCounter(ctx, pf.VersionID); err != nil {
log.Error("Error incrementing download counter: %v", err)
}
}