mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
fix erroring
This commit is contained in:
parent
db911d1bce
commit
0ccc2685cf
2 changed files with 10 additions and 5 deletions
|
@ -150,6 +150,7 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
}
|
}
|
||||||
if len(config.File) > 0 {
|
if len(config.File) > 0 {
|
||||||
config.File = filepath.Clean(config.File)
|
config.File = filepath.Clean(config.File)
|
||||||
|
log.Debugf("config.File: %s", config.File)
|
||||||
if config.File == "stdin" {
|
if config.File == "stdin" {
|
||||||
c.Yes = true
|
c.Yes = true
|
||||||
f, err := ioutil.TempFile(".", "croc-stdin-")
|
f, err := ioutil.TempFile(".", "croc-stdin-")
|
||||||
|
@ -204,7 +205,7 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
if c.DontEncrypt {
|
if c.DontEncrypt {
|
||||||
c.File.IsEncrypted = false
|
c.File.IsEncrypted = false
|
||||||
}
|
}
|
||||||
|
log.Debug("made new connection")
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +224,7 @@ func (c *Connection) cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) Run() error {
|
func (c *Connection) Run() error {
|
||||||
|
defer log.Flush()
|
||||||
// catch the Ctl+C
|
// catch the Ctl+C
|
||||||
catchCtlC := make(chan os.Signal, 2)
|
catchCtlC := make(chan os.Signal, 2)
|
||||||
signal.Notify(catchCtlC, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(catchCtlC, os.Interrupt, syscall.SIGTERM)
|
||||||
|
@ -239,6 +241,7 @@ func (c *Connection) Run() error {
|
||||||
if c.IsSender {
|
if c.IsSender {
|
||||||
fsize, err := FileSize(path.Join(c.File.Path, c.File.Name))
|
fsize, err := FileSize(path.Join(c.File.Path, c.File.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if fsize < MAX_NUMBER_THREADS*BUFFERSIZE {
|
if fsize < MAX_NUMBER_THREADS*BUFFERSIZE {
|
||||||
|
@ -280,11 +283,13 @@ func (c *Connection) Run() error {
|
||||||
var err error
|
var err error
|
||||||
c.File.Hash, err = HashFile(path.Join(c.File.Path, c.File.Name))
|
c.File.Hash, err = HashFile(path.Join(c.File.Path, c.File.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// get file size
|
// get file size
|
||||||
c.File.Size, err = FileSize(c.File.Name)
|
c.File.Size, err = FileSize(path.Join(c.File.Path, c.File.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
main.go
6
main.go
|
@ -47,7 +47,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
defer log.Flush()
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "croc"
|
app.Name = "croc"
|
||||||
app.Version = version
|
app.Version = version
|
||||||
|
@ -97,12 +97,12 @@ func main() {
|
||||||
} else {
|
} else {
|
||||||
c, err := NewConnection(appOptions)
|
c, err := NewConnection(appOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error! Please submit the following error to https://github.com/schollz/croc/issues:\n\n'%s'\n\n", err.Error())
|
fmt.Printf("Error! Please submit the following error to https://github.com/schollz/croc/issues:\n\n'NewConnection: %s'\n\n", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = c.Run()
|
err = c.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error! Please submit the following error to https://github.com/schollz/croc/issues:\n\n'%s'\n\n", err.Error())
|
fmt.Printf("Error! Please submit the following error to https://github.com/schollz/croc/issues:\n\n'Run: %s'\n\n", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue