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:
parent
a225a08dbc
commit
11ab8a8078
@ -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")
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user