Skip to content

Commit

Permalink
Remove path before comparing file names
Browse files Browse the repository at this point in the history
  • Loading branch information
dude333 committed Jul 15, 2020
1 parent 94660b2 commit 9cf8f59
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -147,7 +148,7 @@ func processQuarterlyReport(db *sql.DB, year int) error {
dataTypes := []string{"BPA", "BPP", "DRE", "DFC_MD", "DFC_MI", "DVA"}

for _, dt := range dataTypes {
pattern := fmt.Sprintf("%s/ITR_CIA_ABERTA_%s_con_%d.csv", dataDir, dt, year)
pattern := fmt.Sprintf("ITR_CIA_ABERTA_%s_con_%d.csv", dt, year)
reqFile, err := findFile(files, pattern)
if err == ErrItemNotFound {
filesCleanup(files)
Expand Down Expand Up @@ -286,7 +287,8 @@ func removeItem(list []string, item string) ([]string, error) {
func findFile(list []string, pattern string) (string, error) {

for i := range list {
if strings.EqualFold(list[i], pattern) {
f := filepath.Base(list[i])
if strings.EqualFold(f, pattern) {
return list[i], nil
}
}
Expand Down

0 comments on commit 9cf8f59

Please sign in to comment.