Skip to content

Commit f7b0307

Browse files
committed
fix: don't use metadata dir for legacy BoltDB
1 parent 8ca5cc8 commit f7b0307

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

internal/dao/dao.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313

1414
// DAO abstracts away the database access
1515
type DAO struct {
16-
stateDir string
16+
stateDir string
17+
metadataDir string
1718
}
1819

1920
// Package is the package information stored in the DB
@@ -24,11 +25,11 @@ type Package struct {
2425

2526
// Open returns a new DAO at the given state directory
2627
func Open(stateDir string) (*DAO, error) {
27-
stateDir = filepath.Join(stateDir, "metadata")
28-
if err := os.Mkdir(stateDir, 0700); err != nil && !os.IsExist(err) {
28+
metadataDir := filepath.Join(stateDir, "metadata")
29+
if err := os.MkdirAll(metadataDir, 0700); err != nil && !os.IsExist(err) {
2930
return nil, errors.WithStack(err)
3031
}
31-
return &DAO{stateDir: stateDir}, nil
32+
return &DAO{stateDir: stateDir, metadataDir: metadataDir}, nil
3233
}
3334

3435
// Dump content of database to w.
@@ -74,7 +75,7 @@ func (d *DAO) DeletePackage(pkgRef string) error {
7475
}
7576

7677
func (d *DAO) metadataPath(pkgRef string) string {
77-
return filepath.Join(d.stateDir, pkgRef+".etag")
78+
return filepath.Join(d.metadataDir, pkgRef+".etag")
7879
}
7980

8081
// TODO: Remove this BBolt code.

0 commit comments

Comments
 (0)