diff --git a/src/api.go b/src/api.go index 928c79b7..8aab2bfd 100644 --- a/src/api.go +++ b/src/api.go @@ -99,6 +99,10 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) { ce.isLocal = true ce.cs.Unlock() c.cs.Unlock() + defer func() { + // delete croc files + ce.cleanup() + }() var ri runInfo ri.err = ce.client(0, channel) ri.bothConnected = ce.bothConnected diff --git a/src/cleanup.go b/src/cleanup.go index 9c3dd871..4416d2c2 100644 --- a/src/cleanup.go +++ b/src/cleanup.go @@ -7,18 +7,12 @@ import ( func (c *Croc) cleanup() { // erase all the croc files and their possible numbers - for i := 0; i < 100; i++ { + for i := 0; i < 16; i++ { fname := c.crocFile + "." + strconv.Itoa(i) - if !exists(fname) { - break - } os.Remove(fname) } - for i := 0; i < 100; i++ { + for i := 0; i < 16; i++ { fname := c.crocFileEncrypted + "." + strconv.Itoa(i) - if !exists(fname) { - break - } os.Remove(fname) } os.Remove(c.crocFile)