|
|
|
@@ -153,7 +153,7 @@ func GetAttachment(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if err := attach.IncreaseDownloadCount(); err != nil { |
|
|
|
if err = increaseDownloadCount(attach, dataSet); err != nil { |
|
|
|
ctx.ServerError("Update", err) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -168,11 +168,10 @@ func GetAttachment(ctx *context.Context) { |
|
|
|
} |
|
|
|
defer fr.Close() |
|
|
|
|
|
|
|
if err := attach.IncreaseDownloadCount(); err != nil { |
|
|
|
if err = increaseDownloadCount(attach, dataSet); err != nil { |
|
|
|
ctx.ServerError("Update", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if err = ServeData(ctx, attach.Name, fr); err != nil { |
|
|
|
ctx.ServerError("ServeData", err) |
|
|
|
return |
|
|
|
@@ -180,3 +179,17 @@ func GetAttachment(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func increaseDownloadCount(attach *models.Attachment, dataSet *models.Dataset) error{ |
|
|
|
if err := attach.IncreaseDownloadCount(); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
if dataSet != nil { |
|
|
|
if err := models.IncreaseDownloadCount(dataSet.ID, dataSet.UserID); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |