Skip to content

Commit 9cf8f59

Browse files
committed
Remove path before comparing file names
1 parent 94660b2 commit 9cf8f59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fetch.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"net/http"
2828
"os"
2929
"path"
30+
"path/filepath"
3031
"strings"
3132
"time"
3233

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

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

288289
for i := range list {
289-
if strings.EqualFold(list[i], pattern) {
290+
f := filepath.Base(list[i])
291+
if strings.EqualFold(f, pattern) {
290292
return list[i], nil
291293
}
292294
}

0 commit comments

Comments
 (0)