Skip to content

Commit 8e08a64

Browse files
committed
Fix duplicates log
1 parent 31da90d commit 8e08a64

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/utils/file_handlers.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ func WriteFileLogs(destinationFolder string, sortedFiles, duplicateFiles []File)
178178
sortedFilesWithDuplicates := []File{}
179179
for _, file := range sortedFiles {
180180
file.Duplicates = GetDuplicates(duplicateFiles, file.Hash)
181-
sortedFilesWithDuplicates = append(sortedFilesWithDuplicates, file)
181+
if len(file.Duplicates) > 0 {
182+
sortedFilesWithDuplicates = append(sortedFilesWithDuplicates, file)
183+
}
182184
}
183185

184186
// Create destination path
@@ -193,13 +195,11 @@ func WriteFileLogs(destinationFolder string, sortedFiles, duplicateFiles []File)
193195
htmlString := "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'/><title>Duplicates</title></head><body><h1>Duplicates</h1><ul>"
194196

195197
for _, file := range sortedFilesWithDuplicates {
196-
if len(file.Duplicates) > 0 {
197-
htmlString = htmlString + "<li><p><a href='file://" + file.Path + "' target='_blank'>" + file.RelativePath + " (" + file.Hash + ")</a></p><ul>"
198-
for _, duplicate := range file.Duplicates {
199-
htmlString = htmlString + "<li><p><a href='file://" + duplicate.Path + "' target='_blank'>" + duplicate.RelativePath + "</a></p></li>"
200-
}
201-
htmlString = htmlString + "</ul></li>"
198+
htmlString = htmlString + "<li><p><a href='file://" + file.Path + "' target='_blank'>" + file.RelativePath + " (" + file.Hash + ")</a></p><ul>"
199+
for _, duplicate := range file.Duplicates {
200+
htmlString = htmlString + "<li><p><a href='file://" + duplicate.Path + "' target='_blank'>" + duplicate.RelativePath + "</a></p></li>"
202201
}
202+
htmlString = htmlString + "</ul></li>"
203203
}
204204

205205
htmlString = htmlString + "</ul></body></html>"

0 commit comments

Comments
 (0)