c572fcfe04
Rename the Go module path from code.gitea.io/gitea to git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire codebase. Scope: - go.mod module declaration - 2,235 Go source files (import paths) - Dockerfile WORKDIR and COPY paths - Swagger API templates - golangci.yml linter config External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea, gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are separate upstream modules. Closes #132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
45 lines
1007 B
Go
45 lines
1007 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !gogit
|
|
|
|
package git
|
|
|
|
import "git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
|
|
|
// Size returns the size of the entry
|
|
func (te *TreeEntry) Size() int64 {
|
|
if te.IsDir() {
|
|
return 0
|
|
} else if te.sized {
|
|
return te.size
|
|
}
|
|
|
|
batch, cancel, err := te.ptree.repo.CatFileBatch(te.ptree.repo.Ctx)
|
|
if err != nil {
|
|
log.Debug("error whilst reading size for %s in %s. Error: %v", te.ID.String(), te.ptree.repo.Path, err)
|
|
return 0
|
|
}
|
|
defer cancel()
|
|
info, err := batch.QueryInfo(te.ID.String())
|
|
if err != nil {
|
|
log.Debug("error whilst reading size for %s in %s. Error: %v", te.ID.String(), te.ptree.repo.Path, err)
|
|
return 0
|
|
}
|
|
|
|
te.size = info.Size
|
|
te.sized = true
|
|
return te.size
|
|
}
|
|
|
|
// Blob returns the blob object the entry
|
|
func (te *TreeEntry) Blob() *Blob {
|
|
return &Blob{
|
|
ID: te.ID,
|
|
name: te.Name(),
|
|
size: te.size,
|
|
gotSize: te.sized,
|
|
repo: te.ptree.repo,
|
|
}
|
|
}
|