add support for delayed quota update

If there are a lot of close uploads, accumulating quota updates can
save you many queries to the data provider
This commit is contained in:
Nicola Murino
2021-04-11 08:38:43 +02:00
parent 4b98f37df1
commit c844fc7477
9 changed files with 324 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/jwtauth/v5"
"github.com/go-chi/render"
"github.com/lestrrat-go/jwx/jwa"
"github.com/drakkan/sftpgo/common"
"github.com/drakkan/sftpgo/dataprovider"
@@ -252,7 +253,7 @@ func (s *httpdServer) updateContextFromCookie(r *http.Request) *http.Request {
}
func (s *httpdServer) initializeRouter() {
s.tokenAuth = jwtauth.New("HS256", utils.GenerateRandomBytes(32), nil)
s.tokenAuth = jwtauth.New(jwa.HS256.String(), utils.GenerateRandomBytes(32), nil)
s.router = chi.NewRouter()
s.router.Use(saveConnectionAddress)