Metadata file not being found should throw an error
This commit is contained in:
parent
16ad80fdeb
commit
6ab7f9f00a
|
@ -10,7 +10,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -33,6 +32,9 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto
|
||||||
metadataPath = filepath.Join(dir, f.Name())
|
metadataPath = filepath.Join(dir, f.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if metadataPath == "" {
|
||||||
|
return errors.New("no metadata file found")
|
||||||
|
}
|
||||||
|
|
||||||
metadataFile, err := fs.Open(metadataPath)
|
metadataFile, err := fs.Open(metadataPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -99,9 +101,9 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto
|
||||||
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Join(dir, filepath.Dir(path)), 0755)
|
err = fs.MkdirAll(filepath.Join(dir, filepath.Dir(path)), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could create all directories")
|
return fmt.Errorf("could not create all directories")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := fs.Create(filepath.Join(dir, path))
|
f, err := fs.Create(filepath.Join(dir, path))
|
||||||
|
|
Loading…
Reference in New Issue