stream file fix

This commit is contained in:
Ben Sarmiento
2023-10-29 16:29:18 +01:00
parent 3c39dca7c2
commit 5c3d159c3f
6 changed files with 51 additions and 35 deletions

View File

@@ -18,6 +18,7 @@ type ConfigInterface interface {
GetDirectories() []string
MeetsConditions(directory, torrentID, torrentName string, fileNames []string) bool
GetOnLibraryUpdate() string
GetNetworkBufferSize() int
}
func LoadZurgConfig(filename string) (ConfigInterface, error) {

View File

@@ -9,10 +9,7 @@ type ZurgConfig struct {
CacheTimeHours int `yaml:"info_cache_time_hours"`
CanRepair bool `yaml:"enable_repair"`
OnLibraryUpdate string `yaml:"on_library_update"`
}
func (z *ZurgConfig) GetVersion() string {
return "v1"
NetworkBufferSize int `yaml:"network_buffer_size"`
}
func (z *ZurgConfig) GetToken() string {
@@ -20,14 +17,23 @@ func (z *ZurgConfig) GetToken() string {
}
func (z *ZurgConfig) GetPort() string {
if z.Port == "" {
return "9999"
}
return z.Port
}
func (z *ZurgConfig) GetNumOfWorkers() int {
if z.NumOfWorkers == 0 {
return 10
}
return z.NumOfWorkers
}
func (z *ZurgConfig) GetRefreshEverySeconds() int {
if z.RefreshEverySeconds == 0 {
return 60
}
return z.RefreshEverySeconds
}
@@ -42,3 +48,10 @@ func (z *ZurgConfig) EnableRepair() bool {
func (z *ZurgConfig) GetOnLibraryUpdate() string {
return z.OnLibraryUpdate
}
func (z *ZurgConfig) GetNetworkBufferSize() int {
if z.NetworkBufferSize == 0 {
return 32 * 1024
}
return z.NetworkBufferSize
}

View File

@@ -17,6 +17,10 @@ func loadV1Config(content []byte) (*ZurgConfigV1, error) {
return &configV1, nil
}
func (z *ZurgConfigV1) GetVersion() string {
return "v1"
}
func (z *ZurgConfigV1) GetDirectories() []string {
rootDirectories := make([]string, len(z.Directories))
i := 0