Skip to content

Commit ed4e6f5

Browse files
committed
Add filename to fancyName if listAll and there's a name clash
1 parent baafe0d commit ed4e6f5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

utils/utils.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
type firmware struct {
1111
Path string
1212
Name string
13+
extra string
1314
IsLoader bool
1415
}
1516

@@ -72,11 +73,33 @@ func GetCompatibleWith(name string) map[string][]firmware {
7273
lowerPath, _ := filepath.Rel(root, path)
7374
lowerPath = strings.ToLower(lowerPath)
7475
_, alreadyPopulated := files[folder]
75-
if listAll || ((fw.MatchString(path) || f.IsLoader) && isPreferred(alreadyPopulated, lowerPath, knownBoards[name])) {
76+
if listAll && !strings.HasPrefix(f.Name, "firmwares") {
77+
files[folder] = append(files[folder], f)
78+
}
79+
if !listAll && (fw.MatchString(path) || f.IsLoader) && isPreferred(alreadyPopulated, lowerPath, knownBoards[name]) {
7680
files[folder] = append(files[folder], f)
7781
}
7882
return nil
7983
})
84+
85+
// check files and add information to fw.Name in case of name clashing
86+
for k := range files {
87+
for i := range files[k] {
88+
for j := range files[k] {
89+
if files[k][i].Name == files[k][j].Name && i != j {
90+
files[k][i].extra = filepath.Base(files[k][i].Path)
91+
}
92+
}
93+
}
94+
}
95+
for k := range files {
96+
for i := range files[k] {
97+
if files[k][i].extra != "" {
98+
files[k][i].Name = files[k][i].Name + " (" + files[k][i].extra + ")"
99+
}
100+
}
101+
}
102+
80103
if err != nil {
81104
return files
82105
}

0 commit comments

Comments
 (0)