mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
show filename + file size early
This commit is contained in:
parent
488b88f9dd
commit
ad2ab1d8da
2 changed files with 6 additions and 8 deletions
13
connect.go
13
connect.go
|
@ -72,7 +72,6 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
c.UseStdout = config.UseStdout
|
c.UseStdout = config.UseStdout
|
||||||
c.Yes = config.Yes
|
c.Yes = config.Yes
|
||||||
c.rate = config.Rate
|
c.rate = config.Rate
|
||||||
c.Local = config.Local
|
|
||||||
|
|
||||||
stat, _ := os.Stdin.Stat()
|
stat, _ := os.Stdin.Stat()
|
||||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
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.Name = path.Base(config.File)
|
||||||
c.File.Path = path.Dir(config.File)
|
c.File.Path = path.Dir(config.File)
|
||||||
|
c.File.Size, _ = FileSize(config.File)
|
||||||
c.IsSender = true
|
c.IsSender = true
|
||||||
} else {
|
} else {
|
||||||
c.IsSender = false
|
c.IsSender = false
|
||||||
|
@ -178,6 +178,11 @@ func (c *Connection) Run() error {
|
||||||
if c.Code == "" {
|
if c.Code == "" {
|
||||||
c.Code = GetRandomName()
|
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")
|
log.Debug("starting relay in case local connections")
|
||||||
relay := NewRelay(&AppConfig{
|
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)
|
fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code)
|
||||||
|
|
||||||
// broadcast local connection from sender
|
// broadcast local connection from sender
|
||||||
|
|
1
main.go
1
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"`
|
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"`
|
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"`
|
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"`
|
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:""`
|
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:""`
|
Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue