forked from TrueCloudLab/rclone
operations: call Rcat in Copy when size is -1 - #2832
This commit is contained in:
parent
6e153781a7
commit
b8b53901e8
1 changed files with 27 additions and 16 deletions
|
@ -287,23 +287,34 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "failed to open source object")
|
err = errors.Wrap(err, "failed to open source object")
|
||||||
} else {
|
} else {
|
||||||
in := accounting.NewAccount(in0, src).WithBuffer() // account and buffer the transfer
|
if src.Size() == -1 {
|
||||||
var wrappedSrc fs.ObjectInfo = src
|
// -1 indicates unknown size. Use Rcat to handle both remotes supporting and not supporting PutStream.
|
||||||
// We try to pass the original object if possible
|
if doUpdate {
|
||||||
if src.Remote() != remote {
|
actionTaken = "Copied (Rcat, replaced existing)"
|
||||||
wrappedSrc = &overrideRemoteObject{Object: src, remote: remote}
|
} else {
|
||||||
}
|
actionTaken = "Copied (Rcat, new)"
|
||||||
if doUpdate {
|
}
|
||||||
actionTaken = "Copied (replaced existing)"
|
dst, err = Rcat(f, remote, in0, src.ModTime())
|
||||||
err = dst.Update(in, wrappedSrc, hashOption)
|
|
||||||
} else {
|
|
||||||
actionTaken = "Copied (new)"
|
|
||||||
dst, err = f.Put(in, wrappedSrc, hashOption)
|
|
||||||
}
|
|
||||||
closeErr := in.Close()
|
|
||||||
if err == nil {
|
|
||||||
newDst = dst
|
newDst = dst
|
||||||
err = closeErr
|
} else {
|
||||||
|
in := accounting.NewAccount(in0, src).WithBuffer() // account and buffer the transfer
|
||||||
|
var wrappedSrc fs.ObjectInfo = src
|
||||||
|
// We try to pass the original object if possible
|
||||||
|
if src.Remote() != remote {
|
||||||
|
wrappedSrc = &overrideRemoteObject{Object: src, remote: remote}
|
||||||
|
}
|
||||||
|
if doUpdate {
|
||||||
|
actionTaken = "Copied (replaced existing)"
|
||||||
|
err = dst.Update(in, wrappedSrc, hashOption)
|
||||||
|
} else {
|
||||||
|
actionTaken = "Copied (new)"
|
||||||
|
dst, err = f.Put(in, wrappedSrc, hashOption)
|
||||||
|
}
|
||||||
|
closeErr := in.Close()
|
||||||
|
if err == nil {
|
||||||
|
newDst = dst
|
||||||
|
err = closeErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue