mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
clean up after local file transfer
This commit is contained in:
parent
551160d601
commit
0ec32e3f9a
2 changed files with 6 additions and 8 deletions
|
@ -99,6 +99,10 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) {
|
||||||
ce.isLocal = true
|
ce.isLocal = true
|
||||||
ce.cs.Unlock()
|
ce.cs.Unlock()
|
||||||
c.cs.Unlock()
|
c.cs.Unlock()
|
||||||
|
defer func() {
|
||||||
|
// delete croc files
|
||||||
|
ce.cleanup()
|
||||||
|
}()
|
||||||
var ri runInfo
|
var ri runInfo
|
||||||
ri.err = ce.client(0, channel)
|
ri.err = ce.client(0, channel)
|
||||||
ri.bothConnected = ce.bothConnected
|
ri.bothConnected = ce.bothConnected
|
||||||
|
|
|
@ -7,18 +7,12 @@ import (
|
||||||
|
|
||||||
func (c *Croc) cleanup() {
|
func (c *Croc) cleanup() {
|
||||||
// erase all the croc files and their possible numbers
|
// 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)
|
fname := c.crocFile + "." + strconv.Itoa(i)
|
||||||
if !exists(fname) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
os.Remove(fname)
|
os.Remove(fname)
|
||||||
}
|
}
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 16; i++ {
|
||||||
fname := c.crocFileEncrypted + "." + strconv.Itoa(i)
|
fname := c.crocFileEncrypted + "." + strconv.Itoa(i)
|
||||||
if !exists(fname) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
os.Remove(fname)
|
os.Remove(fname)
|
||||||
}
|
}
|
||||||
os.Remove(c.crocFile)
|
os.Remove(c.crocFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue