Skip to content

Commit 2fa46ed

Browse files
committed
Create data dir if not found on 'core update-index'
Fix #6
1 parent e6559d3 commit 2fa46ed

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

commands/core/update_index.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func updateIndexes() {
5757
// TODO: This should be in packagemanager......
5858
func updateIndex(URL *url.URL) {
5959
logrus.WithField("url", URL).Print("Updating index")
60-
coreIndexPath := commands.Config.IndexesDir().Join(path.Base(URL.Path))
60+
indexDirPath := commands.Config.IndexesDir()
61+
coreIndexPath := indexDirPath.Join(path.Base(URL.Path))
6162

6263
tmpFile, err := ioutil.TempFile("", "")
6364
if err != nil {
@@ -80,6 +81,11 @@ func updateIndex(URL *url.URL) {
8081
os.Exit(commands.ErrNetwork)
8182
}
8283

84+
if err := indexDirPath.MkdirAll(); err != nil {
85+
formatter.PrintError(err, "Can't create data directory "+indexDirPath.String())
86+
os.Exit(commands.ErrGeneric)
87+
}
88+
8389
if err := paths.New(tmpFile.Name()).CopyTo(coreIndexPath); err != nil {
8490
formatter.PrintError(err, "Error saving downloaded index "+URL.String())
8591
os.Exit(commands.ErrGeneric)

0 commit comments

Comments
 (0)