Skip to content

Commit

Permalink
Fix config parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Sep 30, 2021
1 parent 2a7979f commit 53da0f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions internal/http/services/archiver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ type svc struct {

// Config holds the config options that need to be passed down to all ocdav handlers
type Config struct {
Prefix string `mapstructure:"prefix"`
GatewaySvc string `mapstructure:"gatewaysvc"`
Timeout int64 `mapstructure:"timeout"`
Insecure bool `mapstructure:"insecure"`
Name string `mapstructure:"name"`
manager.Config
Prefix string `mapstructure:"prefix"`
GatewaySvc string `mapstructure:"gatewaysvc"`
Timeout int64 `mapstructure:"timeout"`
Insecure bool `mapstructure:"insecure"`
Name string `mapstructure:"name"`
MaxNumFiles int64 `mapstructure:"max_num_files"`
MaxSize int64 `mapstructure:"max_size"`
}

func init() {
Expand Down Expand Up @@ -166,7 +167,10 @@ func (s *svc) Handler() http.Handler {
return
}

arch, err := manager.NewArchiver(files, s.walker, s.downloader, s.config.Config)
arch, err := manager.NewArchiver(files, s.walker, s.downloader, manager.Config{
MaxNumFiles: s.config.MaxNumFiles,
MaxSize: s.config.MaxSize,
})
if err != nil {
s.log.Error().Msg(err.Error())
rw.WriteHeader(http.StatusInternalServerError)
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/archiver/manager/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const (

// Config is the config for the Archiver
type Config struct {
MaxNumFiles int64 `mapstructure:"max_num_files"`
MaxSize int64 `mapstructure:"max_size"`
MaxNumFiles int64
MaxSize int64
}

// Archiver is the struct able to create an archive
Expand Down

0 comments on commit 53da0f2

Please sign in to comment.