mirror of https://github.com/schollz/croc.git
stdout should erase file
This commit is contained in:
parent
eceddb364e
commit
ecfdb2d440
|
@ -8,6 +8,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -367,16 +368,24 @@ func (c *Client) transfer(options TransferOptions) (err error) {
|
||||||
var done bool
|
var done bool
|
||||||
data, err = c.conn[0].Receive()
|
data, err = c.conn[0].Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
done, err = c.processMessage(data)
|
done, err = c.processMessage(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
if done {
|
if done {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Options.Stdout && !c.Options.IsSender {
|
||||||
|
pathToFile := path.Join(
|
||||||
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].FolderRemote,
|
||||||
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].Name,
|
||||||
|
)
|
||||||
|
os.Remove(pathToFile)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,6 +729,14 @@ func (c *Client) receiveData(i int) {
|
||||||
if c.TotalChunksTransfered == len(c.CurrentFileChunks) || c.TotalSent == c.FilesToTransfer[c.FilesToTransferCurrentNum].Size {
|
if c.TotalChunksTransfered == len(c.CurrentFileChunks) || c.TotalSent == c.FilesToTransfer[c.FilesToTransferCurrentNum].Size {
|
||||||
log.Debug("finished receiving!")
|
log.Debug("finished receiving!")
|
||||||
c.CurrentFile.Close()
|
c.CurrentFile.Close()
|
||||||
|
if c.Options.Stdout {
|
||||||
|
pathToFile := path.Join(
|
||||||
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].FolderRemote,
|
||||||
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].Name,
|
||||||
|
)
|
||||||
|
b, _ := ioutil.ReadFile(pathToFile)
|
||||||
|
fmt.Print(string(b))
|
||||||
|
}
|
||||||
log.Debug("sending close-sender")
|
log.Debug("sending close-sender")
|
||||||
err = message.Send(c.conn[0], c.Key, message.Message{
|
err = message.Send(c.conn[0], c.Key, message.Message{
|
||||||
Type: "close-sender",
|
Type: "close-sender",
|
||||||
|
|
Loading…
Reference in New Issue