Add --max-size flag to limit size of repositories (#72)

* Add --max-size flag to limit repository size

* Only update repo size on successful write

* Use initial size as current size for first SaveBlob

* Apply LimitReader to request body

* Use HTTP 413 for size overage responses

* Refactor size limiting; do checks after every write

* Remove extra commented lines, d'oh

* Account for deleting blobs when counting space usage

* Remove extra commented line

* Fix unrelated bug (inverted err check)

* Update comment to trigger new CI build
This commit is contained in:
Matt Holt 2018-06-14 15:53:29 -06:00 committed by GitHub
parent 6f412e6a8a
commit a87d968870
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 153 additions and 27 deletions

4
mux.go
View file

@ -12,7 +12,7 @@ import (
"goji.io/pat"
)
func (s Server) debugHandler(next http.Handler) http.Handler {
func (s *Server) debugHandler(next http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s", r.Method, r.URL)
@ -20,7 +20,7 @@ func (s Server) debugHandler(next http.Handler) http.Handler {
})
}
func (s Server) logHandler(next http.Handler) http.Handler {
func (s *Server) logHandler(next http.Handler) http.Handler {
accessLog, err := os.OpenFile(s.Log, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
log.Fatalf("error: %v", err)