mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
accounting: fix panic due to server-side copy fallback
This commit is contained in:
parent
661dc568f3
commit
d98d1be3fe
|
@ -115,6 +115,20 @@ func (tr *Transfer) Done(err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Reset allows to switch the Account to another transfer method.
|
||||
func (tr *Transfer) Reset() {
|
||||
tr.mu.RLock()
|
||||
acc := tr.acc
|
||||
tr.acc = nil
|
||||
tr.mu.RUnlock()
|
||||
|
||||
if acc != nil {
|
||||
if err := acc.Close(); err != nil {
|
||||
fs.LogLevelPrintf(fs.Config.StatsLogLevel, nil, "can't close account: %+v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Account returns reader that knows how to keep track of transfer progress.
|
||||
func (tr *Transfer) Account(in io.ReadCloser) *Account {
|
||||
tr.mu.Lock()
|
||||
|
|
|
@ -312,6 +312,9 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj
|
|||
} else {
|
||||
_ = in.Close()
|
||||
}
|
||||
if err == fs.ErrorCantCopy {
|
||||
tr.Reset() // skip incomplete accounting - will be overwritten by the manual copy below
|
||||
}
|
||||
} else {
|
||||
err = fs.ErrorCantCopy
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user