shade: fix potential crash in directory move

DirMove discarded the error from the destination check and read the
response status code, so a failure with no HTTP response panicked.
Other errors were reported as the destination existing; they are now
returned.

Thanks to @manus-pi for finding this problem.
This commit is contained in:
Nick Craig-Wood committed 2026-09-22 11:03:16 +01:00
1 parent e2cd9a5dfb
commit 35abcadfc7
1 file changed
+5 -3
+5 -3
View File
@@ -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
}