Skip to content

Commit

Permalink
check and cleanup cache for old files (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth authored May 15, 2024
1 parent 6c56a42 commit 2931619
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -98,7 +99,20 @@ func main() {
log.Fatal(err)
}

tmpPath, tmpErr := os.MkdirTemp(cacheDir, "package-scanner-*")
tmpPathPattern := "package-scanner-*"

// clean up old cache dir files if present
if dirs, err := filepath.Glob(path.Join(cacheDir, tmpPathPattern)); err != nil {
log.Error(err)
} else {
for _, dir := range dirs {
if err := os.RemoveAll(dir); err != nil {
log.Error(err)
}
}
}

tmpPath, tmpErr := os.MkdirTemp(cacheDir, tmpPathPattern)
if tmpErr != nil {
log.Fatal(tmpErr)
}
Expand Down

0 comments on commit 2931619

Please sign in to comment.