Skip to content

Commit

Permalink
Download all files if the initial dir does not exist. fixes #538
Browse files Browse the repository at this point in the history
  Workaround panic from nil dereference in error case
  • Loading branch information
m29h committed Mar 12, 2024
1 parent 6ccab04 commit bec40e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/server/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ func (s *searcher) refreshData(initialDir string) (*DownloadStats, error) {
lastDataRefreshFailure.WithLabelValues("SDNs").Set(float64(time.Now().Unix()))
stats.Errors = append(stats.Errors, fmt.Errorf("OFAC: %v", err))
}
if results == nil {
results = &ofac.Results{}
}

sdns := precomputeSDNs(results.SDNs, results.Addresses, s.pipe)
adds := precomputeAddresses(results.Addresses)
Expand Down
6 changes: 2 additions & 4 deletions pkg/download/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ func (dl *Downloader) GetFiles(dir string, namesAndSources map[string]string) (m
}

// Check the initial directory for files we don't need to download
localFiles, err := os.ReadDir(dir)
if err != nil {
return nil, fmt.Errorf("readdir %s: %v", dir, err)
}
// do not treat an nonexisting directory as error
localFiles, _ := os.ReadDir(dir)

var mu sync.Mutex
out := make(map[string]io.ReadCloser)
Expand Down

0 comments on commit bec40e7

Please sign in to comment.