File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,15 +7,17 @@ import (
77 "io"
88 "net"
99 "os"
10+ "os/signal"
1011 "path"
1112 "strconv"
1213 "strings"
1314 "sync"
15+ "syscall"
1416 "time"
1517
1618 humanize "github.com/dustin/go-humanize"
1719 "github.com/schollz/progressbar"
18- "github.com/schollz/tarinator-go"
20+ tarinator "github.com/schollz/tarinator-go"
1921
2022 "github.com/pkg/errors"
2123 log "github.com/sirupsen/logrus"
@@ -100,7 +102,27 @@ func NewConnection(flags *Flags) (*Connection, error) {
100102 return c , nil
101103}
102104
105+ func (c * Connection ) cleanup () {
106+ log .Debug ("cleaning" )
107+ for id := 1 ; id <= 8 ; id ++ {
108+ os .Remove (path .Join (c .Path , c .File .Name + ".enc." + strconv .Itoa (id )))
109+ }
110+ os .Remove (path .Join (c .Path , c .File .Name + ".enc" ))
111+
112+ }
113+
103114func (c * Connection ) Run () error {
115+ // catch the Ctl+C
116+ catchCtlC := make (chan os.Signal , 2 )
117+ signal .Notify (catchCtlC , os .Interrupt , syscall .SIGTERM )
118+ go func () {
119+ <- catchCtlC
120+ c .cleanup ()
121+ fmt .Println ("\n Exiting" )
122+ os .Exit (1 )
123+ }()
124+ defer c .cleanup ()
125+
104126 forceSingleThreaded := false
105127 if c .IsSender {
106128 fsize , err := FileSize (path .Join (c .File .Path , c .File .Name ))
You can’t perform that action at this time.
0 commit comments