mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	fix attachment file size limit in server backend (#35519)
fix #35512 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -6,7 +6,6 @@ package git | ||||
| import ( | ||||
| 	"crypto/sha1" | ||||
| 	"encoding/hex" | ||||
| 	"io" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| @@ -68,32 +67,6 @@ func ParseBool(value string) (result, valid bool) { | ||||
| 	return intValue != 0, true | ||||
| } | ||||
|  | ||||
| // LimitedReaderCloser is a limited reader closer | ||||
| type LimitedReaderCloser struct { | ||||
| 	R io.Reader | ||||
| 	C io.Closer | ||||
| 	N int64 | ||||
| } | ||||
|  | ||||
| // Read implements io.Reader | ||||
| func (l *LimitedReaderCloser) Read(p []byte) (n int, err error) { | ||||
| 	if l.N <= 0 { | ||||
| 		_ = l.C.Close() | ||||
| 		return 0, io.EOF | ||||
| 	} | ||||
| 	if int64(len(p)) > l.N { | ||||
| 		p = p[0:l.N] | ||||
| 	} | ||||
| 	n, err = l.R.Read(p) | ||||
| 	l.N -= int64(n) | ||||
| 	return n, err | ||||
| } | ||||
|  | ||||
| // Close implements io.Closer | ||||
| func (l *LimitedReaderCloser) Close() error { | ||||
| 	return l.C.Close() | ||||
| } | ||||
|  | ||||
| func HashFilePathForWebUI(s string) string { | ||||
| 	h := sha1.New() | ||||
| 	_, _ = h.Write([]byte(s)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user