From 5cf4d7c103b6d6506990c1b80f5fd5eb3251aa2d Mon Sep 17 00:00:00 2001 From: Zack Date: Thu, 6 Jun 2024 10:19:23 -0700 Subject: [PATCH] update: imohash samples more of the file --- src/utils/utils.go | 7 ++++--- src/utils/utils_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/utils.go b/src/utils/utils.go index 4b48555..f05e24d 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -186,15 +186,16 @@ func MD5HashFile(fname string, doShowProgress bool) (hash256 []byte, err error) return } +var imofull = imohash.NewCustom(0, 0) +var imopartial = imohash.NewCustom(16*16*8*1024, 128*1024) + // IMOHashFile returns imohash func IMOHashFile(fname string) (hash []byte, err error) { - b, err := imohash.SumFile(fname) + b, err := imopartial.SumFile(fname) hash = b[:] return } -var imofull = imohash.NewCustom(0, 0) - // IMOHashFileFull returns imohash of full file func IMOHashFileFull(fname string) (hash []byte, err error) { b, err := imofull.SumFile(fname) diff --git a/src/utils/utils_test.go b/src/utils/utils_test.go index a479189..a309422 100644 --- a/src/utils/utils_test.go +++ b/src/utils/utils_test.go @@ -108,7 +108,7 @@ func TestIMOHashFile(t *testing.T) { defer os.Remove("bigfile.test") b, err := IMOHashFile("bigfile.test") assert.Nil(t, err) - assert.Equal(t, "c0d1e123ca94148ffea146137684ebb9", fmt.Sprintf("%x", b)) + assert.Equal(t, "c0d1e12301e6c635f6d4a8ea5c897437", fmt.Sprintf("%x", b)) } func TestXXHashFile(t *testing.T) {