mirror of https://github.com/schollz/croc.git
reduce complexity
This commit is contained in:
parent
07c20e2cde
commit
cfbd65be31
|
@ -167,8 +167,7 @@ type TransferOptions struct {
|
||||||
KeepPathInRemote bool
|
KeepPathInRemote bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send will send the specified file
|
func (c *Client) sendCollectFiles(options TransferOptions) (err error) {
|
||||||
func (c *Client) Send(options TransferOptions) (err error) {
|
|
||||||
c.FilesToTransfer = make([]FileInfo, len(options.PathToFiles))
|
c.FilesToTransfer = make([]FileInfo, len(options.PathToFiles))
|
||||||
totalFilesSize := int64(0)
|
totalFilesSize := int64(0)
|
||||||
for i, pathToFile := range options.PathToFiles {
|
for i, pathToFile := range options.PathToFiles {
|
||||||
|
@ -225,8 +224,17 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
if len(c.FilesToTransfer) == 1 {
|
if len(c.FilesToTransfer) == 1 {
|
||||||
fname = fmt.Sprintf("'%s'", c.FilesToTransfer[0].Name)
|
fname = fmt.Sprintf("'%s'", c.FilesToTransfer[0].Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "Sending %s (%s)\n", fname, utils.ByteCountDecimal(totalFilesSize))
|
fmt.Fprintf(os.Stderr, "Sending %s (%s)\n", fname, utils.ByteCountDecimal(totalFilesSize))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send will send the specified file
|
||||||
|
func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
|
err = c.sendCollectFiles(options)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
otherRelay := ""
|
otherRelay := ""
|
||||||
if c.Options.RelayAddress != models.DEFAULT_RELAY {
|
if c.Options.RelayAddress != models.DEFAULT_RELAY {
|
||||||
otherRelay = "--relay " + c.Options.RelayAddress + " "
|
otherRelay = "--relay " + c.Options.RelayAddress + " "
|
||||||
|
|
Loading…
Reference in New Issue