Skip to content

Commit

Permalink
🐛 only decompile for code snips when file isnt present
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed Aug 11, 2023
1 parent 54d8d87 commit 5294a47
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions provider/internal/java/snipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,19 @@ func (p *javaProvider) GetCodeSnip(u uri.URI, loc engine.Location) (string, erro
javaFileName = fmt.Sprintf("%v.java", javaFileName[0:i])
}

cmd := exec.Command("jar", "xf", filepath.Base(jarPath))
cmd.Dir = filepath.Dir(jarPath)
err := cmd.Run()
if err != nil {
fmt.Printf("\n java%v", err)
return "", err
javaFileAbsolutePath := filepath.Join(filepath.Dir(jarPath), filepath.Dir(path), javaFileName)

if _, err := os.Stat(javaFileAbsolutePath); err != nil {
cmd := exec.Command("jar", "xf", filepath.Base(jarPath))
cmd.Dir = filepath.Dir(jarPath)
err := cmd.Run()
if err != nil {
fmt.Printf("\n java%v", err)
return "", err
}
}
snip, err := p.scanFile(filepath.Join(filepath.Dir(jarPath), filepath.Dir(path), javaFileName), loc)

snip, err := p.scanFile(javaFileAbsolutePath, loc)
if err != nil {
fmt.Printf("\n%v", err)
return "", err
Expand Down

0 comments on commit 5294a47

Please sign in to comment.