diff --git a/lv.go b/lv.go index 05e5c99..f0b51cc 100644 --- a/lv.go +++ b/lv.go @@ -122,9 +122,11 @@ func add() { Created: time.Now().UnixMilli(), Version: max + 1, }) + + fmt.Println("meta:", meta) + storage.SaveMeta(util.ToHashHex(fullPath), meta) storage.CopyData(fullPath, meta.Versions[len(meta.Versions)-1]) - fmt.Println("version copied") } func del() { diff --git a/util/hash.go b/util/hash.go index abc2229..e7faeb3 100644 --- a/util/hash.go +++ b/util/hash.go @@ -1,12 +1,13 @@ package util import ( - "crypto/sha1" - "encoding/hex" + "crypto/md5" + "fmt" + "io" ) func ToHashHex(filePath string) string { - s1 := sha1.New() - buf := s1.Sum([]byte(filePath)) - return hex.EncodeToString(buf) + h := md5.New() + io.WriteString(h, filePath) + return fmt.Sprintf("%x", h.Sum(nil)) }