mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
multi: specify DB filename when opening clientdb
To make it possible to open any DB in the debug CLI, we allow specifying the file name too instead of only the path.
This commit is contained in:
parent
394c6c1747
commit
9714deb848
4 changed files with 7 additions and 7 deletions
|
|
@ -51,7 +51,7 @@ func newTestDB(t *testing.T) (*DB, func()) {
|
|||
t.Fatalf("unable to create temp dir: %v", err)
|
||||
}
|
||||
|
||||
db, err := New(tempDir)
|
||||
db, err := New(tempDir, DBFilename)
|
||||
if err != nil {
|
||||
os.RemoveAll(tempDir)
|
||||
t.Fatalf("unable to create new db: %v", err)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// dbFilename is the default filename of the client database.
|
||||
dbFilename = "pool.db"
|
||||
// DBFilename is the default filename of the client database.
|
||||
DBFilename = "pool.db"
|
||||
|
||||
// dbFilePermission is the default permission the client database file
|
||||
// is created with.
|
||||
|
|
@ -29,9 +29,9 @@ type DB struct {
|
|||
}
|
||||
|
||||
// New creates a new bolt database that can be found at the given directory.
|
||||
func New(dir string) (*DB, error) {
|
||||
func New(dir, fileName string) (*DB, error) {
|
||||
firstInit := false
|
||||
path := filepath.Join(dir, dbFilename)
|
||||
path := filepath.Join(dir, fileName)
|
||||
|
||||
// If the database file does not exist yet, create its directory.
|
||||
if !fileExists(path) {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ func newManagerHarness(t *testing.T) *managerHarness {
|
|||
tempDir, err := ioutil.TempDir("", "client-db")
|
||||
require.NoError(t, err)
|
||||
|
||||
db, err := clientdb.New(tempDir)
|
||||
db, err := clientdb.New(tempDir, clientdb.DBFilename)
|
||||
if err != nil {
|
||||
_ = os.RemoveAll(tempDir)
|
||||
t.Fatalf("unable to create new db: %v", err)
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ func (s *Server) setupClient() error {
|
|||
|
||||
// Open the main database.
|
||||
var err error
|
||||
s.db, err = clientdb.New(s.cfg.BaseDir)
|
||||
s.db, err = clientdb.New(s.cfg.BaseDir, clientdb.DBFilename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue