From 626f0d18861487817c083604962cb275434adbc7 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 20 Mar 2019 17:17:15 +0000 Subject: [PATCH] copy: account for server side copy bytes and obey --max-transfer --- fs/operations/operations.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 1b65ffda7..0a265f140 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -274,9 +274,14 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec // is same underlying remote actionTaken = "Copied (server side copy)" 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) if err == nil { dst = newDst + accounting.Stats.Bytes(dst.Size()) // account the bytes for the server side transfer } } else { err = fs.ErrorCantCopy