mirror of
https://github.com/rclone/rclone.git
synced 2025-01-23 22:59:27 +01:00
dropbox: make across config server side Move/Copy/DirMove fallback to copy
If we are doing a cross remote transfer then attempting a Move/Copy/DirMove where we don't have permission gives `from_lookup/not_found` errors. This patch notices that error and only if we are doing a cross remote transfer it engages the fallback where the file is streamed. See: https://forum.rclone.org/t/dropbox-io-error-movedir-failed-from-lookup-not-found-when-try-to-move-copy-works/34088
This commit is contained in:
parent
2c78f56d48
commit
4660f5f15d
@ -1078,6 +1078,15 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.CopyV2APIError:
|
||||
// If we are doing a cross remote transfer then from_lookup/not_found indicates we
|
||||
// don't have permission to read the source, so engage the slow path
|
||||
if srcObj.fs != f && e.EndpointError != nil && e.EndpointError.FromLookup != nil && e.EndpointError.FromLookup.Tag == files.LookupErrorNotFound {
|
||||
fs.Debugf(srcObj, "Copy failed attempting fallback: %v", err)
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("copy failed: %w", err)
|
||||
}
|
||||
|
||||
@ -1139,6 +1148,15 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.MoveV2APIError:
|
||||
// If we are doing a cross remote transfer then from_lookup/not_found indicates we
|
||||
// don't have permission to read the source, so engage the slow path
|
||||
if srcObj.fs != f && e.EndpointError != nil && e.EndpointError.FromLookup != nil && e.EndpointError.FromLookup.Tag == files.LookupErrorNotFound {
|
||||
fs.Debugf(srcObj, "Move failed attempting fallback: %v", err)
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("move failed: %w", err)
|
||||
}
|
||||
|
||||
@ -1257,6 +1275,15 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.MoveV2APIError:
|
||||
// If we are doing a cross remote transfer then from_lookup/not_found indicates we
|
||||
// don't have permission to read the source, so engage the slow path
|
||||
if srcFs != f && e.EndpointError != nil && e.EndpointError.FromLookup != nil && e.EndpointError.FromLookup.Tag == files.LookupErrorNotFound {
|
||||
fs.Debugf(srcFs, "DirMove failed attempting fallback: %v", err)
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("MoveDir failed: %w", err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user