diff --git a/docs/api/batch.md b/docs/api/batch.md index ec59db8e..f8dbc6a1 100644 --- a/docs/api/batch.md +++ b/docs/api/batch.md @@ -83,8 +83,9 @@ omitted. * `href` - String URL to download the object. * `header` - Optional hash of String HTTP header key/value pairs to apply to the request. - * `expires_in` - Nanoseconds after local client time when transfer will - expire. Preferred over `expires_at` if both are provided. + * `expires_in` - Whole number of seconds after local client time when + transfer will expire. Preferred over `expires_at` if both are provided. + Maximum of 9223372036, minimum of -9223372036. * `expires_at` - String ISO 8601 formatted timestamp for when the given action expires (usually due to a temporary token). diff --git a/lfsapi/ssh.go b/lfsapi/ssh.go index 86661d5e..c574c63e 100644 --- a/lfsapi/ssh.go +++ b/lfsapi/ssh.go @@ -58,11 +58,11 @@ type sshAuthResponse struct { Href string `json:"href"` Header map[string]string `json:"header"` ExpiresAt time.Time `json:"expires_at"` - ExpiresIn time.Duration `json:"expires_in"` + ExpiresIn int64 `json:"expires_in"` } func (r *sshAuthResponse) IsExpiredWithin(d time.Duration) (time.Time, bool) { - return tools.IsExpiredAtOrIn(d, r.ExpiresAt, r.ExpiresIn) + return tools.IsExpiredAtOrIn(d, r.ExpiresAt, time.Duration(r.ExpiresIn)*time.Second) } type sshAuthClient struct { diff --git a/test/cmd/lfstest-gitserver.go b/test/cmd/lfstest-gitserver.go index 65a49c16..7100978d 100644 --- a/test/cmd/lfstest-gitserver.go +++ b/test/cmd/lfstest-gitserver.go @@ -180,7 +180,7 @@ type lfsLink struct { Href string `json:"href"` Header map[string]string `json:"header,omitempty"` ExpiresAt time.Time `json:"expires_at,omitempty"` - ExpiresIn time.Duration `json:"expires_in,omitempty"` + ExpiresIn int64 `json:"expires_in,omitempty"` } type lfsError struct { @@ -484,10 +484,10 @@ func serveExpired(a *lfsLink, repo, handler string) *lfsLink { case "expired-absolute": a.ExpiresAt = at case "expired-relative": - a.ExpiresIn = dur + a.ExpiresIn = -5 case "expired-both": a.ExpiresAt = at - a.ExpiresIn = dur + a.ExpiresIn = -5 } return a diff --git a/test/cmd/ssh-echo.go b/test/cmd/ssh-echo.go index dbfbf076..8c150b33 100644 --- a/test/cmd/ssh-echo.go +++ b/test/cmd/ssh-echo.go @@ -14,7 +14,7 @@ type sshResponse struct { Href string `json:"href"` Header map[string]string `json:"header"` ExpiresAt time.Time `json:"expires_at,omitempty"` - ExpiresIn time.Duration `json:"expires_in,omitempty"` + ExpiresIn int64 `json:"expires_in,omitempty"` } func main() { @@ -40,10 +40,10 @@ func main() { case "ssh-expired-absolute": r.ExpiresAt = time.Now().Add(-5 * time.Minute) case "ssh-expired-relative": - r.ExpiresIn = -5 * time.Minute + r.ExpiresIn = -5 case "ssh-expired-both": r.ExpiresAt = time.Now().Add(-5 * time.Minute) - r.ExpiresIn = -5 * time.Minute + r.ExpiresIn = -5 } json.NewEncoder(os.Stdout).Encode(r) diff --git a/tq/schemas/http-batch-response-schema.json b/tq/schemas/http-batch-response-schema.json index ddfd5805..975c3ab5 100644 --- a/tq/schemas/http-batch-response-schema.json +++ b/tq/schemas/http-batch-response-schema.json @@ -14,6 +14,11 @@ "type": "object", "additionalProperties": true }, + "expires_in": { + "type": "number", + "maximum": 9223372036, + "minimum": -9223372036 + }, "expires_at": { "type": "string" } diff --git a/tq/transfer.go b/tq/transfer.go index 65922e96..d54872d7 100644 --- a/tq/transfer.go +++ b/tq/transfer.go @@ -113,11 +113,11 @@ type Action struct { Href string `json:"href"` Header map[string]string `json:"header,omitempty"` ExpiresAt time.Time `json:"expires_at,omitempty"` - ExpiresIn time.Duration `json:"expires_in,omitempty"` + ExpiresIn int64 `json:"expires_in,omitempty"` } func (a *Action) IsExpiredWithin(d time.Duration) (time.Time, bool) { - return tools.IsExpiredAtOrIn(d, a.ExpiresAt, a.ExpiresIn) + return tools.IsExpiredAtOrIn(d, a.ExpiresAt, time.Duration(a.ExpiresIn)*time.Second) } type ActionSet map[string]*Action