From c173987d7be9c643548310839a6f118c1114ecf7 Mon Sep 17 00:00:00 2001 From: "Mr. Joja" Date: Tue, 24 Oct 2017 22:40:48 -0600 Subject: [PATCH 1/4] added file/folder transfer time --- connect.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connect.go b/connect.go index 13808a6..fc80328 100644 --- a/connect.go +++ b/connect.go @@ -212,6 +212,7 @@ func (c *Connection) runClient() error { "sender?": c.IsSender, }) + startTime:= time.Now() c.HashedCode = Hash(c.Code) var wg sync.WaitGroup @@ -407,6 +408,7 @@ func (c *Connection) runClient() error { return nil } fmt.Println("\nFile sent.") + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.since(startTime)))) } else { // Is a Receiver if responses.notPresent { fmt.Println("Sender is not ready. Use -wait to wait until sender connects.") @@ -466,6 +468,7 @@ func (c *Connection) runClient() error { fmt.Printf("\nReceived file written to %s\n", path.Join(c.Path, c.File.Name)) } + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.since(startTime)))) } return nil } From dd6cf4ba7631a34f06de712cc7060214fdf78bfd Mon Sep 17 00:00:00 2001 From: "Mr. Joja" Date: Tue, 24 Oct 2017 23:51:11 -0600 Subject: [PATCH 2/4] fixed typo in time.Since function --- connect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connect.go b/connect.go index fc80328..903ef8c 100644 --- a/connect.go +++ b/connect.go @@ -408,7 +408,7 @@ func (c *Connection) runClient() error { return nil } fmt.Println("\nFile sent.") - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.since(startTime)))) + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.Since(startTime)))) } else { // Is a Receiver if responses.notPresent { fmt.Println("Sender is not ready. Use -wait to wait until sender connects.") @@ -468,7 +468,7 @@ func (c *Connection) runClient() error { fmt.Printf("\nReceived file written to %s\n", path.Join(c.Path, c.File.Name)) } - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.since(startTime)))) + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.Since(startTime)))) } return nil } From 414507ab1cc584e03a1d0fcd13a70db4bf6a06f9 Mon Sep 17 00:00:00 2001 From: "Mr. Joja" Date: Wed, 25 Oct 2017 00:28:41 -0600 Subject: [PATCH 3/4] fix types mismatched with transfer duration --- connect.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connect.go b/connect.go index 903ef8c..1552fae 100644 --- a/connect.go +++ b/connect.go @@ -408,7 +408,8 @@ func (c *Connection) runClient() error { return nil } fmt.Println("\nFile sent.") - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.Since(startTime)))) + timeSinceStart:= time.Since(startTime) / time.Second + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) } else { // Is a Receiver if responses.notPresent { fmt.Println("Sender is not ready. Use -wait to wait until sender connects.") @@ -467,8 +468,8 @@ func (c *Connection) runClient() error { } else { fmt.Printf("\nReceived file written to %s\n", path.Join(c.Path, c.File.Name)) } - - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(c.File.Size/time.Since(startTime)))) + timeSinceStart:= time.Since(startTime) / time.Second + fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) } return nil } From 36b546406da78df2a546cebe5258447a1c7532bb Mon Sep 17 00:00:00 2001 From: "Mr. Joja" Date: Wed, 25 Oct 2017 01:01:01 -0600 Subject: [PATCH 4/4] removed duplicated code on transfer speed message --- connect.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/connect.go b/connect.go index 1552fae..e6d2d57 100644 --- a/connect.go +++ b/connect.go @@ -408,8 +408,6 @@ func (c *Connection) runClient() error { return nil } fmt.Println("\nFile sent.") - timeSinceStart:= time.Since(startTime) / time.Second - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) } else { // Is a Receiver if responses.notPresent { fmt.Println("Sender is not ready. Use -wait to wait until sender connects.") @@ -468,9 +466,9 @@ func (c *Connection) runClient() error { } else { fmt.Printf("\nReceived file written to %s\n", path.Join(c.Path, c.File.Name)) } - timeSinceStart:= time.Since(startTime) / time.Second - fmt.Printf("\nTransfered with an average speed of %s/s", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) } + timeSinceStart:= time.Since(startTime) / time.Second + fmt.Printf("\nTransfered at an average speed of %s/s", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) return nil }