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" "strings"
"time" "time"
"github.com/schollz/croc/src/zipper"
log "github.com/cihub/seelog" log "github.com/cihub/seelog"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/schollz/croc/src/compress" "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) log.Debugf("got hash: %x", message)
if bytes.Equal(hash256, message) { if bytes.Equal(hash256, message) {
c.WriteMessage(websocket.BinaryMessage, []byte("ok")) 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 { } else {
c.WriteMessage(websocket.BinaryMessage, []byte("not")) c.WriteMessage(websocket.BinaryMessage, []byte("not"))
return errors.New("file corrupted") return errors.New("file corrupted")

View File

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