diff --git a/bin/evening_detective_server b/bin/evening_detective_server index e1284d7..80952cb 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/cmd/evening_detective_server/main.go b/cmd/evening_detective_server/main.go index 2000560..029567e 100644 --- a/cmd/evening_detective_server/main.go +++ b/cmd/evening_detective_server/main.go @@ -354,28 +354,32 @@ func customErrorHandler( ) { var maxBytesErr *http.MaxBytesError if errors.As(err, &maxBytesErr) { - writeTooLargeError(w, marshaler) + writeTooLargeError(w, marshaler, r.URL.Path) return } if status.Code(err) == codes.ResourceExhausted { switch r.URL.Path { case "/api/files/upload", "/api/scenarios/archive": - writeTooLargeError(w, marshaler) + writeTooLargeError(w, marshaler, r.URL.Path) return } } if status.Code(err) == codes.InvalidArgument && strings.Contains(status.Convert(err).Message(), "request body too large") { - writeTooLargeError(w, marshaler) + writeTooLargeError(w, marshaler, r.URL.Path) return } runtime.DefaultHTTPErrorHandler(ctx, mux, marshaler, w, r, err) } -func writeTooLargeError(w http.ResponseWriter, marshaler runtime.Marshaler) { +func writeTooLargeError(w http.ResponseWriter, marshaler runtime.Marshaler, route string) { + limit := maxFileSize + if route == "/api/scenarios/archive" { + limit = scenario_archive.MaxArchiveSize() + } w.Header().Set("Content-Type", marshaler.ContentType(nil)) w.WriteHeader(http.StatusRequestEntityTooLarge) _ = marshaler.NewEncoder(w).Encode(map[string]string{ - "error": fmt.Sprintf("файл слишком большой (лимит %d МБ)", maxFileSize>>20), + "error": fmt.Sprintf("файл слишком большой (лимит %d МБ)", limit>>20), }) } diff --git a/internal/modules/scenario_archive/archive.go b/internal/modules/scenario_archive/archive.go index 5a4f334..daef2d2 100644 --- a/internal/modules/scenario_archive/archive.go +++ b/internal/modules/scenario_archive/archive.go @@ -17,10 +17,10 @@ import ( ) var ( - maxArchiveSize = 32 << 20 - maxUnpackedSize = 128 << 20 + maxArchiveSize = 256 << 20 + maxUnpackedSize = 256 << 20 maxEntries = 500 - maxEntrySize = 32 << 20 + maxEntrySize = 256 << 20 maxPackSize = 256 << 20 )