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

filefabric: fix listing after change of from field from "int" to int.

Nick Craig-Wood1b44035e4501
diff --git a/backend/filefabric/api/types.go b/backend/filefabric/api/types.go
index e3b80e6c0..9ba415326 100644
--- a/backend/filefabric/api/types.go
+++ b/backend/filefabric/api/types.go
@@ -5,6 +5,7 @@ package api
import (
"bytes"
+ "encoding/json"
"fmt"
"reflect"
"strings"
@@ -51,6 +52,23 @@ func (t Time) String() string {
return time.Time(t).UTC().Format(timeFormatParameters)
}
+// Int represents an integer which can be represented in JSON as a
+// quoted integer or an integer.
+type Int int
+
+// MarshalJSON turns a Int into JSON
+func (i *Int) MarshalJSON() (out []byte, err error) {
+ return json.Marshal((*int)(i))
+}
+
+// UnmarshalJSON turns JSON into a Int
+func (i *Int) UnmarshalJSON(data []byte) error {
+ if len(data) >= 2 && data[0] == '"' && data[len(data)-1] == '"' {
+ data = data[1 : len(data)-1]
+ }
+ return json.Unmarshal(data, (*int)(i))
+}
+
// Status return returned in all status responses
type Status struct {
Code string `json:"status"`
@@ -115,7 +133,7 @@ type GetFolderContentsResponse struct {
Total int `json:"total,string"`
Items []Item `json:"filelist"`
Folder Item `json:"folder"`
- From int `json:"from,string"`
+ From Int `json:"from"`
//Count int `json:"count"`
Pid string `json:"pid"`
RefreshResult Status `json:"refreshresult"`