don't re-use a TempDir path
Rather than creating and immediately removing a temp directory to get a random path name, fetch files into a subdirectory.
This commit is contained in:
parent
28c46d1a90
commit
15dc75720e
|
@ -3,6 +3,7 @@ package module
|
|||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-getter"
|
||||
)
|
||||
|
@ -37,13 +38,10 @@ func GetCopy(dst, src string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// FIXME: This isn't completely safe. Creating and removing our temp path
|
||||
// exposes where to race to inject files.
|
||||
if err := os.RemoveAll(tmpDir); err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
tmpDir = filepath.Join(tmpDir, "module")
|
||||
|
||||
// Get to that temporary dir
|
||||
if err := getter.Get(tmpDir, src); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue