mirror of https://github.com/schollz/croc.git
fix hash file
This commit is contained in:
parent
274fab92a1
commit
828f83601d
|
@ -89,8 +89,9 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
|
|||
return err
|
||||
}
|
||||
// await file
|
||||
f, err := os.Create("out")
|
||||
f, err := os.Create(fstats.Name)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
bytesWritten := 0
|
||||
|
@ -149,8 +150,9 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
|
|||
bar.Finish()
|
||||
|
||||
// check hash
|
||||
hash256, err := utils.HashFile("out")
|
||||
hash256, err := utils.HashFile(fstats.Name)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
// HashFile returns the md5 hash of a file
|
||||
func HashFile(fname string) (hash256 []byte, err error) {
|
||||
f, err := os.Open("file.txt")
|
||||
f, err := os.Open(fname)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue