mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
fix getting hash
This commit is contained in:
parent
6911848141
commit
4fd172b6fc
2 changed files with 7 additions and 3 deletions
|
@ -55,7 +55,7 @@ func (s subscription) readPump() {
|
|||
messageType, msg, err := c.ws.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||
log.Errorf("error: %v", err)
|
||||
log.Debugf("unexpected close: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -41,6 +42,8 @@ func Send(done chan struct{}, c *websocket.Conn, fname string, codephrase string
|
|||
|
||||
func send(c *websocket.Conn, fname string, codephrase string) (err error) {
|
||||
// check that the file exists
|
||||
fname, err = filepath.Abs(fname)
|
||||
_, filename := filepath.Split(fname)
|
||||
f, err := os.Open(fname)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -50,10 +53,11 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) {
|
|||
return err
|
||||
}
|
||||
// get stats
|
||||
fstats := models.FileStats{fstat.Name(), fstat.Size(), fstat.ModTime(), fstat.IsDir(), fstat.Name()}
|
||||
fstats := models.FileStats{filename, fstat.Size(), fstat.ModTime(), fstat.IsDir(), fstat.Name()}
|
||||
if fstats.IsDir {
|
||||
// zip the directory
|
||||
fstats.SentName, err = zipper.ZipFile(fname, true)
|
||||
fname = fstats.SentName
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -165,7 +169,7 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) {
|
|||
|
||||
bar.Finish()
|
||||
log.Debug("send hash to finish file")
|
||||
fileHash, err := utils.HashFile(fstats.SentName)
|
||||
fileHash, err := utils.HashFile(fname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue