hash too long
This commit is contained in:
parent
22425fc471
commit
53cc29b44f
4
lv.go
4
lv.go
|
@ -122,9 +122,11 @@ func add() {
|
||||||
Created: time.Now().UnixMilli(),
|
Created: time.Now().UnixMilli(),
|
||||||
Version: max + 1,
|
Version: max + 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fmt.Println("meta:", meta)
|
||||||
|
|
||||||
storage.SaveMeta(util.ToHashHex(fullPath), meta)
|
storage.SaveMeta(util.ToHashHex(fullPath), meta)
|
||||||
storage.CopyData(fullPath, meta.Versions[len(meta.Versions)-1])
|
storage.CopyData(fullPath, meta.Versions[len(meta.Versions)-1])
|
||||||
fmt.Println("version copied")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func del() {
|
func del() {
|
||||||
|
|
11
util/hash.go
11
util/hash.go
|
@ -1,12 +1,13 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"fmt"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToHashHex(filePath string) string {
|
func ToHashHex(filePath string) string {
|
||||||
s1 := sha1.New()
|
h := md5.New()
|
||||||
buf := s1.Sum([]byte(filePath))
|
io.WriteString(h, filePath)
|
||||||
return hex.EncodeToString(buf)
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue