|
@@ -272,21 +272,32 @@ func compareFolder(folder string) {
|
|
|
loadAllHashFiles(folder)
|
|
|
|
|
|
// putting all hashes into one big map key = hash, value list of files with that hash
|
|
|
+ size := len(hashes)
|
|
|
index := make(map[string][]string)
|
|
|
+ count = 0
|
|
|
for _, hashFile := range hashes {
|
|
|
+ count++
|
|
|
+ if count%100 == 0 {
|
|
|
+ fmt.Printf("%d (%d) merging\n", count, size)
|
|
|
+ }
|
|
|
for filename, hash := range hashFile.Hashes {
|
|
|
values := index[hash]
|
|
|
if values == nil {
|
|
|
values = make([]string, 0)
|
|
|
}
|
|
|
- values = append(values, fmt.Sprintf("%s/%s", hashFile.Path, filename))
|
|
|
- index[hash] = values
|
|
|
+ filepath := fmt.Sprintf("%s/%s", hashFile.Path, filename)
|
|
|
+ _, err := os.Stat(filepath)
|
|
|
+ if err == nil {
|
|
|
+ values = append(values, filepath)
|
|
|
+ index[hash] = values
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// sorting list of files for every hash and deleting hashes with only 1 entry
|
|
|
- size := len(index)
|
|
|
+ size = len(index)
|
|
|
myHashes := make([]string, 0)
|
|
|
+ count = 0
|
|
|
for hash, values := range index {
|
|
|
count++
|
|
|
if count%100 == 0 {
|