@@ -665,16 +665,24 @@ func tagsHandler(w http.ResponseWriter, r *http.Request) {
665665// should be appended to. For new databases it's not needed, but for existing databases it's required (its used to
666666// detect out of date / conflicting uploads)
667667func uploadHandler (w http.ResponseWriter , r * http.Request ) {
668- // Set the maximum accepted database size for uploading
669- r .Body = http .MaxBytesReader (w , r .Body , com .MaxDatabaseSize * 1024 * 1024 )
670-
671668 // Authenticate the request
672669 loggedInUser , err := checkAuth (w , r )
673670 if err != nil {
674671 jsonErr (w , err .Error (), http .StatusUnauthorized )
675672 return
676673 }
677674
675+ // Set the maximum accepted database size for uploading
676+ oversizeAllowed := false
677+ for _ , user := range com .Conf .Environment .SizeOverrideUsers {
678+ if loggedInUser == user {
679+ oversizeAllowed = true
680+ }
681+ }
682+ if ! oversizeAllowed {
683+ r .Body = http .MaxBytesReader (w , r .Body , com .MaxDatabaseSize * 1024 * 1024 )
684+ }
685+
678686 // Extract the database name and (optional) commit ID for the database from the request
679687 _ , dbName , commitID , err := com .GetFormODC (r )
680688 if err != nil {
@@ -691,14 +699,15 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
691699 }
692700
693701 // Check whether the uploaded database is too large
694- // TODO: Have a list of users (from the config.toml file) which don't have this check applied
695- if r .ContentLength > (com .MaxDatabaseSize * 1024 * 1024 ) {
696- jsonErr (w ,
697- fmt .Sprintf ("Database is too large. Maximum database upload size is %d MB, yours is %d MB" ,
698- com .MaxDatabaseSize , r .ContentLength / 1024 / 1024 ), http .StatusBadRequest )
699- log .Println (fmt .Sprintf ("'%s' attempted to upload an oversized database %d MB in size. Limit is %d MB\n " ,
700- loggedInUser , r .ContentLength / 1024 / 1024 , com .MaxDatabaseSize ))
701- return
702+ if ! oversizeAllowed {
703+ if r .ContentLength > (com .MaxDatabaseSize * 1024 * 1024 ) {
704+ jsonErr (w ,
705+ fmt .Sprintf ("Database is too large. Maximum database upload size is %d MB, yours is %d MB" ,
706+ com .MaxDatabaseSize , r .ContentLength / 1024 / 1024 ), http .StatusBadRequest )
707+ log .Println (fmt .Sprintf ("'%s' attempted to upload an oversized database %d MB in size. Limit is %d MB\n " ,
708+ loggedInUser , r .ContentLength / 1024 / 1024 , com .MaxDatabaseSize ))
709+ return
710+ }
702711 }
703712
704713 // Process the upload
0 commit comments