Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

box: fix about: cannot unmarshal number 1.0e+18 into Go struct field

Nick Craig-Wooddc95f36bc105
diff --git a/backend/box/api/types.go b/backend/box/api/types.go
index 275dea950..f9abadd1d 100644
--- a/backend/box/api/types.go
+++ b/backend/box/api/types.go
@@ -271,9 +271,9 @@ type User struct {
ModifiedAt time.Time `json:"modified_at"`
Language string `json:"language"`
Timezone string `json:"timezone"`
- SpaceAmount int64 `json:"space_amount"`
- SpaceUsed int64 `json:"space_used"`
- MaxUploadSize int64 `json:"max_upload_size"`
+ SpaceAmount float64 `json:"space_amount"`
+ SpaceUsed float64 `json:"space_used"`
+ MaxUploadSize float64 `json:"max_upload_size"`
Status string `json:"status"`
JobTitle string `json:"job_title"`
Phone string `json:"phone"`
diff --git a/fs/types.go b/fs/types.go
index c664ce162..dc3cc0cef 100644
--- a/fs/types.go
+++ b/fs/types.go
@@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"io"
+ "math"
"time"
"github.com/rclone/rclone/fs/hash"
@@ -335,9 +336,15 @@ type FlaggerNP interface {
}
// NewUsageValue makes a valid value
-func NewUsageValue(value int64) *int64 {
+func NewUsageValue[T interface {
+ int64 | uint64 | float64
+}](value T) *int64 {
p := new(int64)
- *p = value
+ if value > T(int64(math.MaxInt64)) {
+ *p = math.MaxInt64
+ } else {
+ *p = int64(value)
+ }
return p
}