Skip to content

Commit

Permalink
Fixed filename problems in scratch space copies and scan result output (
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanford committed Feb 12, 2017
1 parent a191183 commit 16c553d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,19 @@ func run() error {
errChan <- ctx.Err()
return
default:
ofile := path.Join(ss.ScratchSpacePath, path.Base(ifile))
ifiledir := path.Dir(ifile)
var ofiledir string
if path.IsAbs(ifiledir) {
ofiledir = path.Clean(path.Join(ss.ScratchSpacePath, ifiledir))
} else {
cwd, err := os.Getwd()
if err != nil {
errChan <- ctx.Err()
return
}
ofiledir = path.Clean(path.Join(ss.ScratchSpacePath, cwd, ifiledir))
}
ofile := path.Join(ofiledir, path.Base(ifile))
if err := copyToScratchSpace(ifile, ofile); err != nil {
errChan <- err
return
Expand Down Expand Up @@ -184,7 +196,7 @@ func run() error {
return
}
scanResults <- ScanResult{
File: strings.Replace(strings.Replace(ur.File, ss.ScratchSpacePath+"/", "", -1), ".goscan-unar", "", -1),
File: strings.Replace(strings.Replace(ur.File, ss.ScratchSpacePath, "", -1), ".goscan-unar", "", -1),
Hits: hits,
}
}
Expand Down Expand Up @@ -274,6 +286,10 @@ func copyToScratchSpace(ifilename, ofilename string) error {
return err
}
defer ifile.Close()
err = os.MkdirAll(path.Dir(ofilename), 0777)
if err != nil {
return err
}
ofile, err := os.Create(ofilename)
if err != nil {
return err
Expand Down

0 comments on commit 16c553d

Please sign in to comment.