|
@@ -8,6 +8,7 @@ import (
|
|
|
"log"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
+ "slices"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
"sync"
|
|
@@ -257,8 +258,7 @@ func compareFolder(folder string) {
|
|
|
values = make([]string, 0)
|
|
|
}
|
|
|
filepath := fmt.Sprintf("%s/%s", hashFile.Path, filename)
|
|
|
- pos := sort.SearchStrings(ignoreLines, filepath)
|
|
|
- if pos == len(ignoreLines) {
|
|
|
+ if !contains(filepath) {
|
|
|
_, err := os.Stat(filepath)
|
|
|
if err == nil {
|
|
|
values = append(values, filepath)
|
|
@@ -320,7 +320,7 @@ func compareFolder(folder string) {
|
|
|
fmt.Println(err)
|
|
|
return
|
|
|
}
|
|
|
- err = ioutil.WriteFile(report, b, 0644)
|
|
|
+ err = os.WriteFile(report, b, 0644)
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
@@ -356,11 +356,24 @@ func compareFolder(folder string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func contains(filepath string) bool {
|
|
|
+ return slices.Contains(ignoreLines, strings.ToLower(filepath))
|
|
|
+}
|
|
|
+
|
|
|
func loadIgnoreFile(filename string) {
|
|
|
- content, err := ioutil.ReadFile(filename)
|
|
|
+ content, err := os.ReadFile(filename)
|
|
|
if err == nil {
|
|
|
- ignoreLines = strings.Split(string(content), "\n")
|
|
|
- sort.Strings(ignoreLines)
|
|
|
+ lines := strings.Split(string(content), "\n")
|
|
|
+ ignoreLines = make([]string, 0)
|
|
|
+ for _, line := range lines {
|
|
|
+ line = strings.TrimSpace(line)
|
|
|
+ line = strings.ToLower(line)
|
|
|
+ line, _ = strings.CutSuffix(line, "\r")
|
|
|
+ if line != "" {
|
|
|
+ ignoreLines = append(ignoreLines, line)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ slices.Sort(ignoreLines)
|
|
|
}
|
|
|
}
|
|
|
|