From ad2ab1d8da19fbd69da608a4af06158c4756623d Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Tue, 24 Apr 2018 22:58:35 -0700 Subject: [PATCH] show filename + file size early --- connect.go | 13 ++++++------- main.go | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/connect.go b/connect.go index 2ab5c85e..4f2cdf0a 100644 --- a/connect.go +++ b/connect.go @@ -72,7 +72,6 @@ func NewConnection(config *AppConfig) (*Connection, error) { c.UseStdout = config.UseStdout c.Yes = config.Yes c.rate = config.Rate - c.Local = config.Local stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { @@ -118,6 +117,7 @@ func NewConnection(config *AppConfig) (*Connection, error) { } c.File.Name = path.Base(config.File) c.File.Path = path.Dir(config.File) + c.File.Size, _ = FileSize(config.File) c.IsSender = true } else { c.IsSender = false @@ -178,6 +178,11 @@ func (c *Connection) Run() error { if c.Code == "" { c.Code = GetRandomName() } + if c.File.IsDir { + fmt.Fprintf(os.Stderr, "Sending %s folder named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name[:len(c.File.Name)-4]) + } else { + fmt.Fprintf(os.Stderr, "Sending %s file named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name) + } log.Debug("starting relay in case local connections") relay := NewRelay(&AppConfig{ @@ -227,12 +232,6 @@ func (c *Connection) Run() error { } } - if c.File.IsDir { - fmt.Fprintf(os.Stderr, "Sending %s folder named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name[:len(c.File.Name)-4]) - } else { - fmt.Fprintf(os.Stderr, "Sending %s file named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name) - - } fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code) // broadcast local connection from sender diff --git a/main.go b/main.go index 2a913a5d..f803bb92 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,6 @@ type AppConfig struct { DontEncrypt bool `yaml:"no-encrypt" flagName:"no-encrypt" flagSName:"g" flagDescribe:"Turn off encryption" default:"false"` UseStdout bool `yaml:"stdout" flagName:"stdout" flagSName:"o" flagDescribe:"Use stdout" default:"false"` Yes bool `yaml:"yes" flagName:"yes" flagSName:"y" flagDescribe:"Automatically accept file" default:"false"` - Local bool `yaml:"local" flagName:"local" flagSName:"lo" flagDescribe:"Use local relay when sending" default:"false"` Server string `yaml:"server" flagName:"server" flagSName:"l" flagDescribe:"Croc relay to use" default:"cowyo.com"` File string `yaml:"send" flagName:"send" flagSName:"s" flagDescribe:"File to send default:""` Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""`