libgit2: Add early return to transferProgressCallback
In transferProgressCallback(), if the received objects is equal to the total objects, return early with OK. Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit is contained in:
parent
afa82bbc7a
commit
d407c824d6
|
@ -59,7 +59,11 @@ func RemoteCallbacks(ctx context.Context, opts *git.AuthOptions) git2go.RemoteCa
|
||||||
// libgit2 it should stop the transfer when the given context is closed (due to
|
// libgit2 it should stop the transfer when the given context is closed (due to
|
||||||
// e.g. a timeout).
|
// e.g. a timeout).
|
||||||
func transferProgressCallback(ctx context.Context) git2go.TransferProgressCallback {
|
func transferProgressCallback(ctx context.Context) git2go.TransferProgressCallback {
|
||||||
return func(_ git2go.TransferProgress) git2go.ErrorCode {
|
return func(p git2go.TransferProgress) git2go.ErrorCode {
|
||||||
|
// Early return if all the objects have been received.
|
||||||
|
if p.ReceivedObjects == p.TotalObjects {
|
||||||
|
return git2go.ErrorCodeOK
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return git2go.ErrorCodeUser
|
return git2go.ErrorCodeUser
|
||||||
|
|
Loading…
Reference in New Issue