Skip to content

Commit

Permalink
pkg/linksharing/sharing: always close the download
Browse files Browse the repository at this point in the history
Prevent orphaned downloads from accumulating.

Change-Id: I753e346d7f15fcb68b3f5aa0e60c206a35fea080
  • Loading branch information
amwolff authored and littleskunk committed Jun 23, 2023
1 parent 0adc0d6 commit 29972b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/linksharing/sharing/present.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func (handler *Handler) presentWithProject(ctx context.Context, w http.ResponseW
if (download || !wrap) && !mapOnly && len(archivePath) == 0 && rangeErr == nil {
d, err := project.DownloadObject(ctx, pr.bucket, pr.realKey, options)
if err == nil {
defer func() {
if err := d.Close(); err != nil {
handler.log.Debug("couldn't close the download", zap.Error(err))
}
}()
// set the actual offset and length
httpRange := optionsToRange(d.Info().System.ContentLength, options)
return handler.showObject(ctx, w, r, pr, project, d.Info(), d, httpRange)
Expand Down

0 comments on commit 29972b9

Please sign in to comment.