Ensure that there is an output file to operate on
parent
e6054fc927
commit
d98a484f87
|
@ -49,19 +49,21 @@ func download(src string, dst string) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
|
||||||
|
return errors.Wrap(err, "mkdir")
|
||||||
|
}
|
||||||
|
|
||||||
// Don't bother with getter.MockGetter, as we don't provide a way to inspect the outcome
|
// Don't bother with getter.MockGetter, as we don't provide a way to inspect the outcome
|
||||||
if Mock {
|
if Mock {
|
||||||
glog.Infof("Mock download: %s -> %s", src, dst)
|
glog.Infof("Mock download: %s -> %s", src, dst)
|
||||||
return nil
|
// Callers expect the file to exist
|
||||||
|
_, err := os.Create(dst)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Politely prevent tests from shooting themselves in the foot
|
// Politely prevent tests from shooting themselves in the foot
|
||||||
if underTest() {
|
if underTest() {
|
||||||
return fmt.Errorf("unmocked download under test, set download.Mock=true")
|
return fmt.Errorf("unmocked download under test")
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
|
|
||||||
return errors.Wrap(err, "mkdir")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("Downloading: %s -> %s", src, dst)
|
glog.Infof("Downloading: %s -> %s", src, dst)
|
||||||
|
|
Loading…
Reference in New Issue