Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Feb 13, 2024
1 parent be74095 commit 8401724
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/sda/sda.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ func Download(c *gin.Context) {
if c.Param("type") == "encrypted" {
end = calculateEncryptedEndPosition(start, end, fileDetails)
contentLength = int(end)
log.Debug("calculated end to", end)
}
if start == 0 && end == 0 {
c.Header("Content-Length", fmt.Sprint(contentLength))
} else {
// Calculate how much we should read (if given)
togo := end - start
log.Debug("partial file! set togo to", togo)
c.Header("Content-Length", fmt.Sprint(togo))
}

Expand Down Expand Up @@ -352,7 +354,10 @@ var calculateEncryptedEndPosition = func(start, end int64, fileDetails *database
log.Debug("headlength size: ", headlength.Size())
bodysize := math.Max(float64(togo-headlength.Size()), 0)
log.Debug("body size: ", bodysize)
bodyEnd = int64(packageSize * math.Ceil(bodysize/packageSize))
log.Debug("#packages: ", math.Ceil(bodysize/packageSize))
endCoord := packageSize * math.Ceil(bodysize/packageSize)
log.Debug("endCoord: ", endCoord)
bodyEnd = int64(math.Min(float64(bodyEnd), endCoord))
log.Debug("body end: ", bodyEnd)
}
log.Debug("setting end: ", headlength.Len()+int(bodyEnd))
Expand Down

0 comments on commit 8401724

Please sign in to comment.