mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2025-05-18 06:01:56 +02:00
Only remember last file
This commit is contained in:
parent
e33d7e2ca0
commit
ff2d4daeda
15
filesmap.go
15
filesmap.go
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// FilesMap is a struct for listing files by Size and Hash to search for duplicates
|
// FilesMap is a struct for listing files by Size and Hash to search for duplicates
|
||||||
type FilesMap struct {
|
type FilesMap struct {
|
||||||
FilesBySize map[int64][]string
|
FilesBySize map[int64]string
|
||||||
|
|
||||||
FilesByHash map[string][]string
|
FilesByHash map[string][]string
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ type FilesMap struct {
|
|||||||
|
|
||||||
func newFilesMap() *FilesMap {
|
func newFilesMap() *FilesMap {
|
||||||
return &FilesMap{
|
return &FilesMap{
|
||||||
FilesBySize: map[int64][]string{},
|
FilesBySize: map[int64]string{},
|
||||||
FilesByHash: map[string][]string{},
|
FilesByHash: map[string][]string{},
|
||||||
FilesHashed: make(chan fileEntry),
|
FilesHashed: make(chan fileEntry),
|
||||||
FilesIncoming: make(chan fileEntry),
|
FilesIncoming: make(chan fileEntry),
|
||||||
@ -40,17 +40,18 @@ func (fm *FilesMap) IncomingWorker() {
|
|||||||
fmt.Println("Incoming", file.path)
|
fmt.Println("Incoming", file.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
files, ok := fm.FilesBySize[file.size]
|
prevFile, ok := fm.FilesBySize[file.size]
|
||||||
if !ok {
|
if !ok {
|
||||||
files = []string{file.path}
|
fm.FilesBySize[file.size] = file.path
|
||||||
fm.FilesBySize[file.size] = files
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(files) == 1 {
|
if prevFile != "" {
|
||||||
fm.FilesHashing <- fileEntry{files[0], file.size, ""}
|
fm.FilesHashing <- fileEntry{prevFile, file.size, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fm.FilesBySize[file.size] = ""
|
||||||
|
|
||||||
fm.FilesHashing <- file
|
fm.FilesHashing <- file
|
||||||
}
|
}
|
||||||
close(fm.FilesHashing)
|
close(fm.FilesHashing)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user