Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/app/api/handlers/v1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func WithMaxImportSize(maxImportSize int64) func(*V1Controller) {
}
}

func WithMaxParseMemory(maxParseMemory int64) func(*V1Controller) {
return func(ctrl *V1Controller) {
ctrl.maxParseMemory = maxParseMemory
}
}

func WithDemoStatus(demoStatus bool) func(*V1Controller) {
return func(ctrl *V1Controller) {
ctrl.isDemo = demoStatus
Expand Down Expand Up @@ -77,6 +83,7 @@ type V1Controller struct {
svc *services.AllServices
maxUploadSize int64
maxImportSize int64
maxParseMemory int64
isDemo bool
allowRegistration bool
bus *eventbus.EventBus
Expand Down
6 changes: 3 additions & 3 deletions backend/app/api/handlers/v1/v1_ctrl_exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ func (ctrl *V1Controller) HandleCollectionImport() errchain.HandlerFunc {
}

// maxImportSize is in MB and applies to the whole request body via the
// path-aware middleware; here we pass it to ParseMultipartForm as the
// memory-vs-disk threshold so larger archives spool gracefully.
if err := r.ParseMultipartForm(ctrl.maxImportSize << 20); err != nil {
// path-aware middleware; here we pass `maxParseMemory` to ParseMultipartForm
// as the memory-vs-disk threshold so larger archives spool gracefully.
if err := r.ParseMultipartForm(ctrl.maxParseMemory << 20); err != nil {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
log.Err(err).Msg("import: parse multipart")
return validate.NewRequestError(err, http.StatusBadRequest)
}
Expand Down
1 change: 1 addition & 0 deletions backend/app/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
a.conf,
v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize),
v1.WithMaxImportSize(a.conf.Web.MaxImportSize),
v1.WithMaxParseMemory(a.conf.Web.MaxParseMemory),
v1.WithRegistration(a.conf.Options.AllowRegistration),
v1.WithDemoStatus(a.conf.Demo), // Disable Password Change in Demo Mode
v1.WithURL(fmt.Sprintf("%s:%s", a.conf.Web.Host, a.conf.Web.Port)),
Expand Down
12 changes: 8 additions & 4 deletions backend/internal/sys/config/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@
// (POST /v1/group/import). Set independently because a full collection
// backup including attachments can be much larger than a single asset
// upload. Defaults to 1 GB.
MaxImportSize int64 `yaml:"max_import_upload" conf:"default:1024"`
ReadTimeout time.Duration `yaml:"read_timeout" conf:"default:10s"`
WriteTimeout time.Duration `yaml:"write_timeout" conf:"default:10s"`
IdleTimeout time.Duration `yaml:"idle_timeout" conf:"default:30s"`
MaxImportSize int64 `yaml:"max_import_size" conf:"default:1024"`
// MaxParseMemory is the amount of memory used when parsing multipart form
// the data that does not fit into this memory will spil to temp files.
// Defaults to 64 MB.
MaxParseMemory int64 `yaml:"max_parse_memory" conf:"default:64"`
ReadTimeout time.Duration `yaml:"read_timeout" conf:"default:10s"`

Check failure on line 104 in backend/internal/sys/config/conf.go

View workflow job for this annotation

GitHub Actions / Backend Server Tests / Go

tag is not aligned, should be: yaml:"read_timeout" conf:"default:10s" (tagalign)
WriteTimeout time.Duration `yaml:"write_timeout" conf:"default:10s"`

Check failure on line 105 in backend/internal/sys/config/conf.go

View workflow job for this annotation

GitHub Actions / Backend Server Tests / Go

tag is not aligned, should be: yaml:"write_timeout" conf:"default:10s" (tagalign)
IdleTimeout time.Duration `yaml:"idle_timeout" conf:"default:30s"`

Check failure on line 106 in backend/internal/sys/config/conf.go

View workflow job for this annotation

GitHub Actions / Backend Server Tests / Go

tag is not aligned, should be: yaml:"idle_timeout" conf:"default:30s" (tagalign)
}

type LabelMakerConf struct {
Expand Down
Loading