1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-23 23:54:17 +03:00

written file should onlybe name

This commit is contained in:
Zack Scholl 2018-09-21 21:59:46 -07:00
parent a225a08dbc
commit 11ab8a8078
2 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,8 @@ import (
"strings"
"time"
"github.com/schollz/croc/src/zipper"
log "github.com/cihub/seelog"
"github.com/gorilla/websocket"
"github.com/schollz/croc/src/compress"
@ -160,7 +162,13 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
log.Debugf("got hash: %x", message)
if bytes.Equal(hash256, message) {
c.WriteMessage(websocket.BinaryMessage, []byte("ok"))
return nil
// open directory
if fstats.IsDir {
err = zipper.UnzipFile(fstats.SentName, fstats.Name)
} else {
err = nil
}
return err
} else {
c.WriteMessage(websocket.BinaryMessage, []byte("not"))
return errors.New("file corrupted")

View File

@ -99,7 +99,7 @@ func ZipFile(fname string, compress bool) (writtenFilename string, err error) {
log.Error(err)
return
}
writtenFilename = newfile.Name()
_, writtenFilename = filepath.Split(newfile.Name())
defer newfile.Close()
defer os.Chdir(curdir)