mirror of
https://github.com/rclone/rclone.git
synced 2025-11-23 21:44:49 +02:00
box: fix about: cannot unmarshal number 1.0e+18 into Go struct field
Before this change rclone about was failing with
cannot unmarshal number 1.0e+18 into Go struct field User.space_amount of type int64
As Box increased Enterprise accounts user.space_amount from 30PB to
1e+18 or 888.178PB returning it as a floating point number, not an integer.
This fix reads it as a float64 and clips it to the maximum value of an
int64 if necessary.
This commit is contained in:
@@ -271,9 +271,9 @@ type User struct {
|
|||||||
ModifiedAt time.Time `json:"modified_at"`
|
ModifiedAt time.Time `json:"modified_at"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
Timezone string `json:"timezone"`
|
Timezone string `json:"timezone"`
|
||||||
SpaceAmount int64 `json:"space_amount"`
|
SpaceAmount float64 `json:"space_amount"`
|
||||||
SpaceUsed int64 `json:"space_used"`
|
SpaceUsed float64 `json:"space_used"`
|
||||||
MaxUploadSize int64 `json:"max_upload_size"`
|
MaxUploadSize float64 `json:"max_upload_size"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
JobTitle string `json:"job_title"`
|
JobTitle string `json:"job_title"`
|
||||||
Phone string `json:"phone"`
|
Phone string `json:"phone"`
|
||||||
|
|||||||
11
fs/types.go
11
fs/types.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rclone/rclone/fs/hash"
|
"github.com/rclone/rclone/fs/hash"
|
||||||
@@ -335,9 +336,15 @@ type FlaggerNP interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewUsageValue makes a valid value
|
// NewUsageValue makes a valid value
|
||||||
func NewUsageValue(value int64) *int64 {
|
func NewUsageValue[T interface {
|
||||||
|
int64 | uint64 | float64
|
||||||
|
}](value T) *int64 {
|
||||||
p := new(int64)
|
p := new(int64)
|
||||||
*p = value
|
if value > T(int64(math.MaxInt64)) {
|
||||||
|
*p = math.MaxInt64
|
||||||
|
} else {
|
||||||
|
*p = int64(value)
|
||||||
|
}
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user