mirror of
https://github.com/rclone/rclone.git
synced 2026-10-09 22:45:26 -04:00
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:
1 parent
e2cd9a5dfb
commit
35abcadfc7
1 file changed
+5
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user