From a1a41aa0c19f8b29410c963b50e71713a0e38e4b Mon Sep 17 00:00:00 2001 From: Caleb Case Date: Wed, 21 Apr 2021 06:56:36 -0400 Subject: [PATCH] backend/tardigrade: use negative offset v1.4.6 of uplink allows us to do a negative offset from the end of the file. This removes a round trip when requesting the last N bytes of a file. Previous to v1.4.6 of uplink it wasn't possible to do a negative offset on download. This meant that to fulfill the semantics of http range headers it was necessary to first fetch the size of the object via a stat call and compute absolute offset and length. --- backend/tardigrade/object.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/backend/tardigrade/object.go b/backend/tardigrade/object.go index 0f18e36dc..40e29b37d 100644 --- a/backend/tardigrade/object.go +++ b/backend/tardigrade/object.go @@ -148,13 +148,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (_ io.ReadC case s && !e: offset = opt.Start case !s && e: - object, err := o.fs.project.StatObject(ctx, bucketName, bucketPath) - if err != nil { - return nil, err - } - - offset = object.System.ContentLength - opt.End - length = opt.End + offset = -opt.End } case *fs.SeekOption: offset = opt.Offset