remove partially sent files

This commit is contained in:
Zack Scholl 2018-07-04 08:43:30 -07:00
parent 34d499127d
commit 09a16cacd5
3 changed files with 3 additions and 1 deletions

View File

@ -114,7 +114,7 @@ func main() {
fmt.Fprintf(c.App.Writer, "lipstick\nkiss\nme\nlipstick\nringo\n")
}
app.Action = func(c *cli.Context) error {
return cr.Receive(c.Args().First())
return receive(c)
}
app.Before = func(c *cli.Context) error {
cr = croc.Init()

View File

@ -133,6 +133,7 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) {
// Receive will receive something through the croc relay
func (c *Croc) Receive(codePhrase string) (err error) {
defer c.cleanup()
log.Debugf("receiving with code phrase: %s", codePhrase)
if !c.NoLocal {
// try to discovery codephrase and server through peer network
discovered, errDiscover := peerdiscovery.Discover(peerdiscovery.Settings{

View File

@ -505,6 +505,7 @@ func (c *Croc) sendFile(filename string, id int, connection net.Conn) error {
// open encrypted file chunk, if it exists
log.Debug("opening encrypted file chunk: " + filename)
defer os.Remove(filename)
file, err := os.Open(filename)
if err != nil {
log.Error(err)