mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
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:
parent
6f412e6a8a
commit
a87d968870
4 changed files with 153 additions and 27 deletions
4
mux.go
4
mux.go
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue