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

shade: fix potential crash in directory move

Nick Craig-Wood35abcadfc701
diff --git a/backend/shade/shade.go b/backend/shade/shade.go
index eacbdc37b..21b533ddf 100644
--- a/backend/shade/shade.go
+++ b/backend/shade/shade.go
@@ -380,9 +380,11 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
//Need to check if destination exists
fullPath := f.buildFullPath(dstRemote)
var response api.ListDirResponse
- res, _ := f.callAPI(ctx, "GET", fmt.Sprintf("/%s/fs/attr?path=%s", f.drive, fullPath), &response)
-
- if res.StatusCode != http.StatusNotFound {
+ res, err := f.callAPI(ctx, "GET", fmt.Sprintf("/%s/fs/attr?path=%s", f.drive, fullPath), &response)
+ if res == nil || res.StatusCode != http.StatusNotFound {
+ if err != nil {
+ return fmt.Errorf("failed to check destination directory: %w", err)
+ }
return fs.ErrorDirExists
}