Skip to content

Commit

Permalink
fix: ensure directory for local registry exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed Sep 10, 2024
1 parent 4c6d23c commit 72932cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cli/localregistry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"log/slog"
"os"
"path/filepath"
"sync"

Expand All @@ -19,7 +20,12 @@ var dbWriteMutex = sync.Mutex{}

func Init() error {
dbPath := filepath.Join(viper.GetString("cache-dir"), "registry.db")
var err error

err := os.MkdirAll(filepath.Dir(dbPath), 0o777)
if err != nil {
return fmt.Errorf("failed to create local registry directory: %w", err)
}

db, err = sql.Open("sqlite", dbPath)
if err != nil {
return fmt.Errorf("failed to open database: %w", err)
Expand Down

0 comments on commit 72932cd

Please sign in to comment.