mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Improve statistic
This commit is contained in:
@@ -437,7 +437,10 @@ func DownloadFile(ip, fid, cfToken string) (string, string, error) {
|
||||
|
||||
if file.StorageID == nil {
|
||||
if file.RedirectUrl != "" {
|
||||
_ = dao.AddResourceDownloadCount(file.ResourceID)
|
||||
err := dao.AddResourceDownloadCount(file.ResourceID)
|
||||
if err != nil {
|
||||
log.Errorf("failed to add resource download count: %v", err)
|
||||
}
|
||||
return file.RedirectUrl, file.Filename, nil
|
||||
}
|
||||
return "", "", model.NewRequestError("file is not available")
|
||||
@@ -454,10 +457,17 @@ func DownloadFile(ip, fid, cfToken string) (string, string, error) {
|
||||
}
|
||||
|
||||
path, err := iStorage.Download(file.StorageKey, file.Filename)
|
||||
if err != nil {
|
||||
log.Error("failed to download file from storage: ", err)
|
||||
return "", "", model.NewInternalServerError("failed to download file from storage")
|
||||
}
|
||||
|
||||
_ = dao.AddResourceDownloadCount(file.ResourceID)
|
||||
err = dao.AddResourceDownloadCount(file.ResourceID)
|
||||
if err != nil {
|
||||
log.Errorf("failed to add resource download count: %v", err)
|
||||
}
|
||||
|
||||
return path, file.Filename, err
|
||||
return path, file.Filename, nil
|
||||
}
|
||||
|
||||
func testFileUrl(url string) (int64, error) {
|
||||
|
@@ -113,10 +113,13 @@ func parseResourceIfPresent(line string, host string) *model.ResourceView {
|
||||
|
||||
func GetResource(id uint, host string) (*model.ResourceDetailView, error) {
|
||||
r, err := dao.GetResourceByID(id)
|
||||
_ = dao.AddResourceViewCount(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = dao.AddResourceViewCount(id)
|
||||
if err != nil {
|
||||
log.Error("AddResourceViewCount error: ", err)
|
||||
}
|
||||
v := r.ToDetailView()
|
||||
if host != "" {
|
||||
related := findRelatedResources(r, host)
|
||||
|
Reference in New Issue
Block a user