From c96acdfe7a37c676ec1bef5fb04e707069c0eabb Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Thu, 13 Feb 2025 15:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8B=E8=BD=BD=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E4=B8=BA0=E7=9A=84=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E8=AE=BF=E9=97=AE=E9=87=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/internal/http/object.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/internal/http/object.go b/client/internal/http/object.go index 4f3ee37..6d140f0 100644 --- a/client/internal/http/object.go +++ b/client/internal/http/object.go @@ -14,6 +14,7 @@ import ( "gitlink.org.cn/cloudream/common/pkgs/logger" cdssdk "gitlink.org.cn/cloudream/common/sdks/storage" "gitlink.org.cn/cloudream/common/sdks/storage/cdsapi" + "gitlink.org.cn/cloudream/common/utils/math2" "gitlink.org.cn/cloudream/storage/client/internal/config" "gitlink.org.cn/cloudream/storage/common/pkgs/downloader" ) @@ -176,7 +177,7 @@ func (s *ObjectService) Download(ctx *gin.Context) { // TODO 当client不在某个代理节点上时如何处理? if config.Cfg().StorageID > 0 { - s.svc.AccessStat.AddAccessCounter(file.Object.ObjectID, file.Object.PackageID, config.Cfg().StorageID, float64(n)/float64(file.Object.Size)) + s.svc.AccessStat.AddAccessCounter(file.Object.ObjectID, file.Object.PackageID, config.Cfg().StorageID, math2.DivOrDefault(float64(n), float64(file.Object.Size), 1)) } } @@ -231,7 +232,7 @@ func (s *ObjectService) DownloadByPath(ctx *gin.Context) { } if config.Cfg().StorageID > 0 { - s.svc.AccessStat.AddAccessCounter(file.Object.ObjectID, file.Object.PackageID, config.Cfg().StorageID, float64(n)/float64(file.Object.Size)) + s.svc.AccessStat.AddAccessCounter(file.Object.ObjectID, file.Object.PackageID, config.Cfg().StorageID, math2.DivOrDefault(float64(n), float64(file.Object.Size), 1)) } }