Skip to content

Commit

Permalink
fix: object downloads failed by dfstore when dfdaemon enabled concurr…
Browse files Browse the repository at this point in the history
…ent (#2328)

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored May 8, 2023
1 parent 2424bc2 commit 3170ad6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/daemon/objectstorage/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (o *objectStorage) getObject(ctx *gin.Context) {
bucketName = params.ID
objectKey = strings.TrimPrefix(params.ObjectKey, string(os.PathSeparator))
filter = query.Filter
rg nethttp.Range
rg *nethttp.Range
err error
)

Expand Down Expand Up @@ -277,11 +277,12 @@ func (o *objectStorage) getObject(ctx *gin.Context) {
// Parse http range header.
rangeHeader := ctx.GetHeader(headers.Range)
if len(rangeHeader) > 0 {
rg, err = nethttp.ParseOneRange(rangeHeader, math.MaxInt64)
rangeValue, err := nethttp.ParseOneRange(rangeHeader, math.MaxInt64)
if err != nil {
ctx.JSON(http.StatusRequestedRangeNotSatisfiable, gin.H{"errors": err.Error()})
return
}
rg = &rangeValue

// Range header in dragonfly is without "bytes=".
urlMeta.Range = strings.TrimLeft(rangeHeader, "bytes=")
Expand All @@ -304,7 +305,7 @@ func (o *objectStorage) getObject(ctx *gin.Context) {
reader, attr, err := o.peerTaskManager.StartStreamTask(ctx, &peer.StreamTaskRequest{
URL: signURL,
URLMeta: urlMeta,
Range: &rg,
Range: rg,
PeerID: o.peerIDGenerator.PeerID(),
})
if err != nil {
Expand Down

0 comments on commit 3170ad6

Please sign in to comment.