1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

Better UI and check for overwriting file

This commit is contained in:
Zack Scholl 2017-10-22 10:44:18 -06:00
parent f8505caa27
commit 1ea8d9196f

View file

@ -13,6 +13,7 @@ import (
"sync" "sync"
"time" "time"
humanize "github.com/dustin/go-humanize"
"github.com/verybluebot/tarinator-go" "github.com/verybluebot/tarinator-go"
"github.com/gosuri/uiprogress" "github.com/gosuri/uiprogress"
@ -193,9 +194,9 @@ func (c *Connection) Run() error {
} }
if c.File.IsDir { if c.File.IsDir {
fmt.Printf("Sending %d byte folder named '%s'\n", c.File.Size, c.File.Name[:len(c.File.Name)-4]) fmt.Printf("Sending %s folder named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name[:len(c.File.Name)-4])
} else { } else {
fmt.Printf("Sending %d byte file named '%s'\n", c.File.Size, c.File.Name) fmt.Printf("Sending %s file named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name)
} }
fmt.Printf("Code is: %s\n", c.Code) fmt.Printf("Code is: %s\n", c.Code)
@ -316,7 +317,11 @@ func (c *Connection) runClient() error {
log.Debugf("meta data received: %v", c.File) log.Debugf("meta data received: %v", c.File)
// have the main thread ask for the okay // have the main thread ask for the okay
if id == 0 { if id == 0 {
fmt.Printf("Receiving file (%d bytes) into: %s\n", c.File.Size, path.Join(c.Path, c.File.Name)) if _, err := os.Stat(path.Join(c.Path, c.File.Name)); os.IsNotExist(err) {
fmt.Printf("Receiving file (%s) into: %s\n", humanize.Bytes(uint64(c.File.Size)), path.Join(c.Path, c.File.Name))
} else {
fmt.Printf("Overwriting file %s (%s)\n", path.Join(c.Path, c.File.Name), humanize.Bytes(uint64(c.File.Size)))
}
var sentFileNames []string var sentFileNames []string
if c.AskPath { if c.AskPath {