From f9ed7553affe630efa2c0200790b6ddf5e8b1481 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 21 Sep 2018 21:55:07 -0700 Subject: [PATCH] use sent name --- src/models/filestats.go | 10 +++++----- src/recipient/recipient.go | 4 ++-- src/sender/sender.go | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/models/filestats.go b/src/models/filestats.go index ddecdbc..7cf13be 100644 --- a/src/models/filestats.go +++ b/src/models/filestats.go @@ -3,9 +3,9 @@ package models import "time" type FileStats struct { - Name string - Size int64 - ModTime time.Time - IsDir bool - DirName string + Name string + Size int64 + ModTime time.Time + IsDir bool + SentName string } diff --git a/src/recipient/recipient.go b/src/recipient/recipient.go index f671f30..0d20199 100644 --- a/src/recipient/recipient.go +++ b/src/recipient/recipient.go @@ -89,7 +89,7 @@ func receive(c *websocket.Conn, codephrase string) (err error) { return err } // await file - f, err := os.Create(fstats.Name) + f, err := os.Create(fstats.SentName) if err != nil { log.Error(err) return err @@ -150,7 +150,7 @@ func receive(c *websocket.Conn, codephrase string) (err error) { bar.Finish() // check hash - hash256, err := utils.HashFile(fstats.Name) + hash256, err := utils.HashFile(fstats.SentName) if err != nil { log.Error(err) return err diff --git a/src/sender/sender.go b/src/sender/sender.go index 7b27bbc..56fd012 100644 --- a/src/sender/sender.go +++ b/src/sender/sender.go @@ -49,16 +49,17 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) { if err != nil { 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 { // zip the directory - fstats.DirName, err = zipper.ZipFile(fname, true) + fstats.SentName, err = zipper.ZipFile(fname, true) if err != nil { return } f.Close() // reopen file - f, err = os.Open(fstats.DirName) + f, err = os.Open(fstats.SentName) if err != nil { return }