diff --git a/connect.go b/connect.go index 88c5f5020..95be58824 100644 --- a/connect.go +++ b/connect.go @@ -150,6 +150,7 @@ func NewConnection(config *AppConfig) (*Connection, error) { } if len(config.File) > 0 { config.File = filepath.Clean(config.File) + log.Debugf("config.File: %s", config.File) if config.File == "stdin" { c.Yes = true f, err := ioutil.TempFile(".", "croc-stdin-") @@ -204,7 +205,7 @@ func NewConnection(config *AppConfig) (*Connection, error) { if c.DontEncrypt { c.File.IsEncrypted = false } - + log.Debug("made new connection") return c, nil } @@ -223,6 +224,7 @@ func (c *Connection) cleanup() { } func (c *Connection) Run() error { + defer log.Flush() // catch the Ctl+C catchCtlC := make(chan os.Signal, 2) signal.Notify(catchCtlC, os.Interrupt, syscall.SIGTERM) @@ -239,6 +241,7 @@ func (c *Connection) Run() error { if c.IsSender { fsize, err := FileSize(path.Join(c.File.Path, c.File.Name)) if err != nil { + log.Error(err) return err } if fsize < MAX_NUMBER_THREADS*BUFFERSIZE { @@ -280,11 +283,13 @@ func (c *Connection) Run() error { var err error c.File.Hash, err = HashFile(path.Join(c.File.Path, c.File.Name)) if err != nil { + log.Error(err) return err } // 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 { + log.Error(err) return err } diff --git a/main.go b/main.go index 4becf1ad2..36f838a61 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,7 @@ func init() { } func main() { - + defer log.Flush() app := cli.NewApp() app.Name = "croc" app.Version = version @@ -97,12 +97,12 @@ func main() { } else { c, err := NewConnection(appOptions) 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 } err = c.Run() 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()) } } }