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
|
||||
type FilesMap struct {
|
||||
FilesBySize map[int64][]string
|
||||
FilesBySize map[int64]string
|
||||
|
||||
FilesByHash map[string][]string
|
||||
|
||||
@ -26,7 +26,7 @@ type FilesMap struct {
|
||||
|
||||
func newFilesMap() *FilesMap {
|
||||
return &FilesMap{
|
||||
FilesBySize: map[int64][]string{},
|
||||
FilesBySize: map[int64]string{},
|
||||
FilesByHash: map[string][]string{},
|
||||
FilesHashed: make(chan fileEntry),
|
||||
FilesIncoming: make(chan fileEntry),
|
||||
@ -40,17 +40,18 @@ func (fm *FilesMap) IncomingWorker() {
|
||||
fmt.Println("Incoming", file.path)
|
||||
}
|
||||
|
||||
files, ok := fm.FilesBySize[file.size]
|
||||
prevFile, ok := fm.FilesBySize[file.size]
|
||||
if !ok {
|
||||
files = []string{file.path}
|
||||
fm.FilesBySize[file.size] = files
|
||||
fm.FilesBySize[file.size] = file.path
|
||||
continue
|
||||
}
|
||||
|
||||
if len(files) == 1 {
|
||||
fm.FilesHashing <- fileEntry{files[0], file.size, ""}
|
||||
if prevFile != "" {
|
||||
fm.FilesHashing <- fileEntry{prevFile, file.size, ""}
|
||||
}
|
||||
|
||||
fm.FilesBySize[file.size] = ""
|
||||
|
||||
fm.FilesHashing <- file
|
||||
}
|
||||
close(fm.FilesHashing)
|
||||
|
Loading…
x
Reference in New Issue
Block a user