Metadata file not being found should throw an error

This commit is contained in:
Mustafa Gezen 2022-05-10 09:35:48 +02:00
parent 16ad80fdeb
commit 6ab7f9f00a
1 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,6 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)
@ -33,6 +32,9 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto
metadataPath = filepath.Join(dir, f.Name())
}
}
if metadataPath == "" {
return errors.New("no metadata file found")
}
metadataFile, err := fs.Open(metadataPath)
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")
}
err = os.MkdirAll(filepath.Join(dir, filepath.Dir(path)), 0755)
err = fs.MkdirAll(filepath.Join(dir, filepath.Dir(path)), 0755)
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))