|
@@ -60,6 +60,7 @@ func main() {
|
|
|
if runtime.GOOS == "windows" {
|
|
|
driveLetter = filepath.VolumeName(myFile) + "/"
|
|
|
}
|
|
|
+
|
|
|
if report != "" {
|
|
|
compareFolder(myFile)
|
|
|
} else {
|
|
@@ -90,7 +91,7 @@ func getSha256Hash(fileStr string) string {
|
|
|
var lock1 = sync.RWMutex{}
|
|
|
var lock2 = sync.RWMutex{}
|
|
|
|
|
|
-func outputHash(fileStr string) {
|
|
|
+func calculateHash(fileStr string) {
|
|
|
var hashFile Fdhashes
|
|
|
doHash := true
|
|
|
dir, fileName := filepath.Split(fileStr)
|
|
@@ -168,7 +169,7 @@ func processFolder(folder string) {
|
|
|
}
|
|
|
if !info.IsDir() {
|
|
|
addWork++
|
|
|
- outputHash(path)
|
|
|
+ calculateHash(path)
|
|
|
if time.Since(startTime).Seconds() > 10.0 {
|
|
|
startTime = time.Now()
|
|
|
saveAllHashFiles()
|
|
@@ -310,28 +311,6 @@ func compareFolder(folder string) {
|
|
|
w.Flush()
|
|
|
}
|
|
|
|
|
|
-func compareFolder2(folder string) {
|
|
|
- loadAllHashFiles(folder)
|
|
|
- size := len(hashes)
|
|
|
- f, err := os.Create("report.txt")
|
|
|
- check(err)
|
|
|
- w := bufio.NewWriter(f)
|
|
|
- count := 0
|
|
|
- for _, hashFile := range hashes {
|
|
|
- count++
|
|
|
- fmt.Printf("%d (%d) checking: %s\n", count, size, hashFile.Path)
|
|
|
- // fmt.Printf("checking: %s\n", hashFile.Path)
|
|
|
- for filename, hash := range hashFile.Hashes {
|
|
|
- if value, found := search(hash, filename, hashFile.Path); found {
|
|
|
- w.WriteString("found identically hash\n")
|
|
|
- w.WriteString(fmt.Sprintf(" src: %s/%s\n", hashFile.Path, filename))
|
|
|
- w.WriteString(fmt.Sprintf(" dest: %s\n", value))
|
|
|
- w.Flush()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func search(srcHash string, exFilename string, exFilepath string) (value string, found bool) {
|
|
|
for _, hashFile := range hashes {
|
|
|
for filename, hash := range hashFile.Hashes {
|