1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 08:02:33 +03:00

use sent name

This commit is contained in:
Zack Scholl 2018-09-21 21:55:07 -07:00
parent 83f199b213
commit f9ed7553af
3 changed files with 11 additions and 10 deletions

View File

@ -7,5 +7,5 @@ type FileStats struct {
Size int64 Size int64
ModTime time.Time ModTime time.Time
IsDir bool IsDir bool
DirName string SentName string
} }

View File

@ -89,7 +89,7 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
return err return err
} }
// await file // await file
f, err := os.Create(fstats.Name) f, err := os.Create(fstats.SentName)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
return err return err
@ -150,7 +150,7 @@ func receive(c *websocket.Conn, codephrase string) (err error) {
bar.Finish() bar.Finish()
// check hash // check hash
hash256, err := utils.HashFile(fstats.Name) hash256, err := utils.HashFile(fstats.SentName)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
return err return err

View File

@ -49,16 +49,17 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) {
if err != nil { if err != nil {
return err return err
} }
fstats := models.FileStats{fstat.Name(), fstat.Size(), fstat.ModTime(), fstat.IsDir(), ""} // get stats
fstats := models.FileStats{fstat.Name(), fstat.Size(), fstat.ModTime(), fstat.IsDir(), fstats.Name()}
if fstats.IsDir { if fstats.IsDir {
// zip the directory // zip the directory
fstats.DirName, err = zipper.ZipFile(fname, true) fstats.SentName, err = zipper.ZipFile(fname, true)
if err != nil { if err != nil {
return return
} }
f.Close() f.Close()
// reopen file // reopen file
f, err = os.Open(fstats.DirName) f, err = os.Open(fstats.SentName)
if err != nil { if err != nil {
return return
} }