Browse Source

new sorting options

Wilfried Klaas 4 years ago
parent
commit
3e8fd7f43c
2 changed files with 15 additions and 4 deletions
  1. 14 3
      GoHash.go
  2. 1 1
      build.cmd

+ 14 - 3
GoHash.go

@@ -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 {

+ 1 - 1
build.cmd

@@ -1,3 +1,3 @@
 go build -ldflags="-s -w" 
-copy GoHash.exe F:\
+copy GoHash.exe G:\
 pause