code.gitea.io/gitea@v1.19.3/modules/git/blob_gogit.go (about)

     1  // Copyright 2015 The Gogs Authors. All rights reserved.
     2  // Copyright 2019 The Gitea Authors. All rights reserved.
     3  // SPDX-License-Identifier: MIT
     4  
     5  //go:build gogit
     6  
     7  package git
     8  
     9  import (
    10  	"io"
    11  
    12  	"github.com/go-git/go-git/v5/plumbing"
    13  )
    14  
    15  // Blob represents a Git object.
    16  type Blob struct {
    17  	ID SHA1
    18  
    19  	gogitEncodedObj plumbing.EncodedObject
    20  	name            string
    21  }
    22  
    23  // DataAsync gets a ReadCloser for the contents of a blob without reading it all.
    24  // Calling the Close function on the result will discard all unread output.
    25  func (b *Blob) DataAsync() (io.ReadCloser, error) {
    26  	return b.gogitEncodedObj.Reader()
    27  }
    28  
    29  // Size returns the uncompressed size of the blob
    30  func (b *Blob) Size() int64 {
    31  	return b.gogitEncodedObj.Size()
    32  }