Skip to content

Commit

Permalink
fix erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Jun 27, 2018
1 parent db911d1 commit 0ccc268
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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-")
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {
}

func main() {

defer log.Flush()
app := cli.NewApp()
app.Name = "croc"
app.Version = version
Expand Down Expand Up @@ -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())
}
}
}
Expand Down

0 comments on commit 0ccc268

Please sign in to comment.