mirror of
https://github.com/rclone/rclone.git
synced 2025-01-09 07:48:19 +01:00
filefabric: fix directory move after API change #5734
The API has changed in the directory move call JSON response from returning a TaskID as a string to returning it as an integer. In other places it is still returned as a string though. This patch allows the TaskID to be an integer or a string in the JSON response and keeps it internally as a string like before.
This commit is contained in:
parent
4f05ece39e
commit
257f5d279a
@ -69,11 +69,29 @@ func (i *Int) UnmarshalJSON(data []byte) error {
|
|||||||
return json.Unmarshal(data, (*int)(i))
|
return json.Unmarshal(data, (*int)(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String represents an string which can be represented in JSON as a
|
||||||
|
// quoted string or an integer.
|
||||||
|
type String string
|
||||||
|
|
||||||
|
// MarshalJSON turns a String into JSON
|
||||||
|
func (s *String) MarshalJSON() (out []byte, err error) {
|
||||||
|
return json.Marshal((*string)(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON turns JSON into a String
|
||||||
|
func (s *String) UnmarshalJSON(data []byte) error {
|
||||||
|
err := json.Unmarshal(data, (*string)(s))
|
||||||
|
if err != nil {
|
||||||
|
*s = String(data)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Status return returned in all status responses
|
// Status return returned in all status responses
|
||||||
type Status struct {
|
type Status struct {
|
||||||
Code string `json:"status"`
|
Code string `json:"status"`
|
||||||
Message string `json:"statusmessage"`
|
Message string `json:"statusmessage"`
|
||||||
TaskID string `json:"taskid"`
|
TaskID String `json:"taskid"`
|
||||||
// Warning string `json:"warning"` // obsolete
|
// Warning string `json:"warning"` // obsolete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ func (f *Fs) Purge(ctx context.Context, dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the the background task to complete if necessary
|
// Wait for the the background task to complete if necessary
|
||||||
func (f *Fs) waitForBackgroundTask(ctx context.Context, taskID string) (err error) {
|
func (f *Fs) waitForBackgroundTask(ctx context.Context, taskID api.String) (err error) {
|
||||||
if taskID == "" || taskID == "0" {
|
if taskID == "" || taskID == "0" {
|
||||||
// No task to wait for
|
// No task to wait for
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user