guard rm temp dirs

This commit is contained in:
zricethezav committed 2018-03-02 17:19:11 -06:00
1 parent 0ed0489c2d
commit c019a9d80d
2 files changed
+8 -3

No files matched your search

+7 -2
View File
@@ -71,7 +71,10 @@ func newOwner() *Owner {
signal.Notify(sigC, os.Interrupt, os.Interrupt)
go func() {
<-sigC
owner.rmTmp()
if opts.Tmp {
owner.rmTmp()
}
os.Exit(ExitFailure)
}()
// if running on local repo, just go right to it.
@@ -203,6 +206,9 @@ func (owner *Owner) auditRepos() int {
exitCode = ExitLeaks
}
}
if opts.Tmp {
owner.rmTmp()
}
return exitCode
}
@@ -218,7 +224,6 @@ func (owner *Owner) failF(format string, args ...interface{}) {
func (owner *Owner) rmTmp() {
log.Printf("removing tmp gitleaks repo for %s\n", owner.name)
os.RemoveAll(owner.path)
os.Exit(ExitFailure)
}
// ownerType returns the owner type extracted from opts.