Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
f088dc4ea1
commit
86e2789960
819 changed files with 38072 additions and 34969 deletions
64
vendor/github.com/go-git/go-billy/v5/util/util.go
generated
vendored
64
vendor/github.com/go-git/go-billy/v5/util/util.go
generated
vendored
|
@ -146,9 +146,8 @@ func nextSuffix() string {
|
|||
// to remove the file when no longer needed.
|
||||
func TempFile(fs billy.Basic, dir, prefix string) (f billy.File, err error) {
|
||||
// This implementation is based on stdlib ioutil.TempFile.
|
||||
|
||||
if dir == "" {
|
||||
dir = os.TempDir()
|
||||
dir = getTempDir(fs)
|
||||
}
|
||||
|
||||
nconflict := 0
|
||||
|
@ -179,7 +178,7 @@ func TempDir(fs billy.Dir, dir, prefix string) (name string, err error) {
|
|||
// This implementation is based on stdlib ioutil.TempDir
|
||||
|
||||
if dir == "" {
|
||||
dir = os.TempDir()
|
||||
dir = getTempDir(fs.(billy.Basic))
|
||||
}
|
||||
|
||||
nconflict := 0
|
||||
|
@ -207,6 +206,15 @@ func TempDir(fs billy.Dir, dir, prefix string) (name string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func getTempDir(fs billy.Basic) string {
|
||||
ch, ok := fs.(billy.Chroot)
|
||||
if !ok || ch.Root() == "" || ch.Root() == "/" || ch.Root() == string(filepath.Separator) {
|
||||
return os.TempDir()
|
||||
}
|
||||
|
||||
return ".tmp"
|
||||
}
|
||||
|
||||
type underlying interface {
|
||||
Underlying() billy.Basic
|
||||
}
|
||||
|
@ -222,3 +230,53 @@ func getUnderlyingAndPath(fs billy.Basic, path string) (billy.Basic, string) {
|
|||
|
||||
return u.Underlying(), path
|
||||
}
|
||||
|
||||
// ReadFile reads the named file and returns the contents from the given filesystem.
|
||||
// A successful call returns err == nil, not err == EOF.
|
||||
// Because ReadFile reads the whole file, it does not treat an EOF from Read
|
||||
// as an error to be reported.
|
||||
func ReadFile(fs billy.Basic, name string) ([]byte, error) {
|
||||
f, err := fs.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
var size int
|
||||
if info, err := fs.Stat(name); err == nil {
|
||||
size64 := info.Size()
|
||||
if int64(int(size64)) == size64 {
|
||||
size = int(size64)
|
||||
}
|
||||
}
|
||||
|
||||
size++ // one byte for final read at EOF
|
||||
// If a file claims a small size, read at least 512 bytes.
|
||||
// In particular, files in Linux's /proc claim size 0 but
|
||||
// then do not work right if read in small pieces,
|
||||
// so an initial read of 1 byte would not work correctly.
|
||||
|
||||
if size < 512 {
|
||||
size = 512
|
||||
}
|
||||
|
||||
data := make([]byte, 0, size)
|
||||
for {
|
||||
if len(data) >= cap(data) {
|
||||
d := append(data[:cap(data)], 0)
|
||||
data = d[:len(data)]
|
||||
}
|
||||
|
||||
n, err := f.Read(data[len(data):cap(data)])
|
||||
data = data[:len(data)+n]
|
||||
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
|
||||
return data, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue