show filename + file size early

This commit is contained in:
Zack Scholl 2018-04-24 22:58:35 -07:00
parent 488b88f9dd
commit ad2ab1d8da
2 changed files with 6 additions and 8 deletions

View File

@ -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

View File

@ -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:""`