copy: account for server side copy bytes and obey --max-transfer
This commit is contained in:
parent
9ee9fe3885
commit
626f0d1886
1 changed files with 5 additions and 0 deletions
|
@ -274,9 +274,14 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec
|
||||||
// is same underlying remote
|
// is same underlying remote
|
||||||
actionTaken = "Copied (server side copy)"
|
actionTaken = "Copied (server side copy)"
|
||||||
if doCopy := f.Features().Copy; doCopy != nil && (SameConfig(src.Fs(), f) || (SameRemoteType(src.Fs(), f) && f.Features().ServerSideAcrossConfigs)) {
|
if doCopy := f.Features().Copy; doCopy != nil && (SameConfig(src.Fs(), f) || (SameRemoteType(src.Fs(), f) && f.Features().ServerSideAcrossConfigs)) {
|
||||||
|
// Check transfer limit for server side copies
|
||||||
|
if fs.Config.MaxTransfer >= 0 && accounting.Stats.GetBytes() >= int64(fs.Config.MaxTransfer) {
|
||||||
|
return nil, accounting.ErrorMaxTransferLimitReached
|
||||||
|
}
|
||||||
newDst, err = doCopy(src, remote)
|
newDst, err = doCopy(src, remote)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dst = newDst
|
dst = newDst
|
||||||
|
accounting.Stats.Bytes(dst.Size()) // account the bytes for the server side transfer
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = fs.ErrorCantCopy
|
err = fs.ErrorCantCopy
|
||||||
|
|
Loading…
Reference in a new issue