diff --git a/src/fetch.go b/src/fetch.go index ee5a499..ca81c6f 100644 --- a/src/fetch.go +++ b/src/fetch.go @@ -214,6 +214,14 @@ func readGitBlob( return fmt.Errorf("git blob %s: %w", hash, err) } + *bytesTransferred += blob.Size + if uint64(*bytesTransferred) > config.Limits.MaxSiteSize.Bytes() { + return fmt.Errorf("%w: fetch exceeds %s limit", + ErrRepositoryTooLarge, + config.Limits.MaxSiteSize.HR(), + ) + } + reader, err := blob.Reader() if err != nil { return fmt.Errorf("git blob open: %w", err) @@ -238,14 +246,6 @@ func readGitBlob( entry.OriginalSize = proto.Int64(blob.Size) entry.CompressedSize = proto.Int64(blob.Size) - *bytesTransferred += blob.Size - if uint64(*bytesTransferred) > config.Limits.MaxSiteSize.Bytes() { - return fmt.Errorf("%w: fetch exceeds %s limit", - ErrRepositoryTooLarge, - config.Limits.MaxSiteSize.HR(), - ) - } - return nil }