mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(indexers): only load definitions with .yaml ext (#188)
This commit is contained in:
parent
fdf69e6403
commit
a966291b38
1 changed files with 45 additions and 39 deletions
|
@ -318,28 +318,31 @@ func (s *service) LoadIndexerDefinitions() error {
|
|||
}
|
||||
|
||||
for _, f := range entries {
|
||||
filePath := "definitions/" + f.Name()
|
||||
fileExtension := filepath.Ext(f.Name())
|
||||
if fileExtension != ".yaml" {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(f.Name(), ".yaml") {
|
||||
log.Trace().Msgf("parsing: %v", filePath)
|
||||
file := "definitions/" + f.Name()
|
||||
|
||||
log.Trace().Msgf("parsing: %v", file)
|
||||
|
||||
var d domain.IndexerDefinition
|
||||
|
||||
data, err := fs.ReadFile(Definitions, filePath)
|
||||
data, err := fs.ReadFile(Definitions, file)
|
||||
if err != nil {
|
||||
log.Error().Stack().Err(err).Msgf("failed reading file: %v", filePath)
|
||||
log.Error().Stack().Err(err).Msgf("failed reading file: %v", file)
|
||||
return err
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(data, &d)
|
||||
if err != nil {
|
||||
log.Error().Stack().Err(err).Msgf("failed unmarshal file: %v", filePath)
|
||||
log.Error().Stack().Err(err).Msgf("failed unmarshal file: %v", file)
|
||||
return err
|
||||
}
|
||||
|
||||
s.indexerDefinitions[d.Identifier] = d
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug().Msgf("Loaded %d indexer definitions", len(s.indexerDefinitions))
|
||||
|
||||
|
@ -368,9 +371,13 @@ func (s *service) LoadCustomIndexerDefinitions() error {
|
|||
customCount := 0
|
||||
|
||||
for _, f := range entries {
|
||||
fileExtension := filepath.Ext(f.Name())
|
||||
if fileExtension != ".yaml" {
|
||||
continue
|
||||
}
|
||||
|
||||
file := filepath.Join(s.config.CustomDefinitions, f.Name())
|
||||
|
||||
if strings.Contains(f.Name(), ".yaml") {
|
||||
log.Trace().Msgf("parsing custom: %v", file)
|
||||
|
||||
var d domain.IndexerDefinition
|
||||
|
@ -392,7 +399,6 @@ func (s *service) LoadCustomIndexerDefinitions() error {
|
|||
|
||||
customCount++
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug().Msgf("Loaded %d custom indexer definitions", customCount)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue