From bef0c23e0080d45f43e674a985608787242dea77 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 10 Jun 2021 12:22:45 +0100 Subject: [PATCH] fichier: make error messages report text from the API See: https://forum.rclone.org/t/1fichier-rclone-does-not-allow-to-rename-files-and-folders-when-you-mount-a-1fichier-disk-drive/24726/24 --- backend/fichier/api.go | 2 +- backend/fichier/fichier.go | 4 ++-- backend/fichier/structs.go | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/fichier/api.go b/backend/fichier/api.go index 3558e5661..51c7bd61b 100644 --- a/backend/fichier/api.go +++ b/backend/fichier/api.go @@ -319,7 +319,7 @@ func (f *Fs) removeFolder(ctx context.Context, name string, folderID int) (respo return nil, errors.Wrap(err, "couldn't remove folder") } if response.Status != "OK" { - return nil, errors.New("Can't remove non-empty dir") + return nil, errors.Errorf("can't remove folder: %s", response.Message) } // fs.Debugf(f, "Removed Folder with id `%s`", directoryID) diff --git a/backend/fichier/fichier.go b/backend/fichier/fichier.go index c46f45c24..753eadf10 100644 --- a/backend/fichier/fichier.go +++ b/backend/fichier/fichier.go @@ -452,7 +452,7 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, return nil, errors.Wrap(err, "couldn't move file") } if resp.Status != "OK" { - return nil, errors.New("couldn't move file") + return nil, errors.Errorf("couldn't move file: %s", resp.Message) } file, err := f.readFileInfo(ctx, resp.URLs[0]) @@ -486,7 +486,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, return nil, errors.Wrap(err, "couldn't move file") } if resp.Status != "OK" { - return nil, errors.New("couldn't move file") + return nil, errors.Errorf("couldn't move file: %s", resp.Message) } file, err := f.readFileInfo(ctx, resp.URLs[0].ToURL) diff --git a/backend/fichier/structs.go b/backend/fichier/structs.go index 40efd0032..c00d05989 100644 --- a/backend/fichier/structs.go +++ b/backend/fichier/structs.go @@ -64,8 +64,9 @@ type MoveFileRequest struct { // MoveFileResponse is the response structure of the corresponding request type MoveFileResponse struct { - Status string `json:"status"` - URLs []string `json:"urls"` + Status string `json:"status"` + Message string `json:"message"` + URLs []string `json:"urls"` } // CopyFileRequest is the request structure of the corresponding request @@ -77,9 +78,10 @@ type CopyFileRequest struct { // CopyFileResponse is the response structure of the corresponding request type CopyFileResponse struct { - Status string `json:"status"` - Copied int `json:"copied"` - URLs []FileCopy `json:"urls"` + Status string `json:"status"` + Message string `json:"message"` + Copied int `json:"copied"` + URLs []FileCopy `json:"urls"` } // FileCopy is used in the the CopyFileResponse