forked from forgejo/forgejo
Add io.Closer
guidelines (#29387)
Co-authored-by: Yarden Shoham <git@yardenshoham.com> (cherry picked from commit ad0a34b492c3d41952ff4648c8bfb7b54c376151)
This commit is contained in:
parent
3723caf762
commit
753f9711e9
7 changed files with 16 additions and 9 deletions
|
@ -115,6 +115,10 @@ func (r *BlameReader) NextPart() (*BlamePart, error) {
|
|||
|
||||
// Close BlameReader - don't run NextPart after invoking that
|
||||
func (r *BlameReader) Close() error {
|
||||
if r.bufferedReader == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := <-r.done
|
||||
r.bufferedReader = nil
|
||||
_ = r.reader.Close()
|
||||
|
|
|
@ -88,16 +88,17 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
|
|||
}
|
||||
|
||||
// Close this repository, in particular close the underlying gogitStorage if this is not nil
|
||||
func (repo *Repository) Close() (err error) {
|
||||
func (repo *Repository) Close() error {
|
||||
if repo == nil || repo.gogitStorage == nil {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
if err := repo.gogitStorage.Close(); err != nil {
|
||||
gitealog.Error("Error closing storage: %v", err)
|
||||
}
|
||||
repo.gogitStorage = nil
|
||||
repo.LastCommitCache = nil
|
||||
repo.tagCache = nil
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
// GoGitRepo gets the go-git repo representation
|
||||
|
|
|
@ -103,7 +103,7 @@ func (repo *Repository) CatFileBatchCheck(ctx context.Context) (WriteCloserError
|
|||
}
|
||||
}
|
||||
|
||||
func (repo *Repository) Close() (err error) {
|
||||
func (repo *Repository) Close() error {
|
||||
if repo == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -123,5 +123,5 @@ func (repo *Repository) Close() (err error) {
|
|||
}
|
||||
repo.LastCommitCache = nil
|
||||
repo.tagCache = nil
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue