Skip to content

Commit

Permalink
Fix: Address GH #2 by adding local short path on discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
yunginnanet committed Jul 3, 2024
1 parent 1158810 commit 2209534
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion bitcask/bitcask.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ func OpenDB(path string) *DB {
// discover is a helper function to discover and initialize all existing bitcask stores at the path.
// caller must hold write lock.
func (db *DB) discover() ([]string, error) {
if db.initialized.Load() {
stores := make([]string, 0, len(db.store))
for store := range db.store {
if store == "" {
continue
}
stores = append(stores, store)
}
return stores, nil
}
stores := make([]string, 0, len(db.store))
errs := make([]error, 0, len(db.store))
if db.store == nil {
Expand Down Expand Up @@ -510,8 +520,11 @@ func (db *DB) CloseAll() error {
}
func (db *DB) addAllStoresToMeta() {
storeMap := db.allStores()
storeNames := make([]string, len(storeMap))
storeNames := make([]string, 0, len(storeMap))
for name := range storeMap {
if name == "" {
continue
}
storeNames = append(storeNames, name)
}
db.meta = db.meta.WithStores(storeNames...)
Expand Down
15 changes: 14 additions & 1 deletion pogreb/pogreb.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,11 @@ func (db *DB) allMetrics() map[string]*pogreb.Metrics {

func (db *DB) addAllStoresToMeta() {
storeMap := db.allStores()
storeNames := make([]string, len(storeMap))
storeNames := make([]string, 0, len(storeMap))
for name := range storeMap {
if name == "" {
continue
}
storeNames = append(storeNames, name)
}
db.meta = db.meta.WithStores(storeNames...)
Expand All @@ -570,6 +573,16 @@ func (db *DB) SyncAll() error {
}

func (db *DB) discover() ([]string, error) {
if db.initialized.Load() {
stores := make([]string, 0, len(db.store))
for name := range db.store {
if name == "" {
continue
}
stores = append(stores, name)
}
return stores, nil
}
stores := make([]string, 0)
errs := make([]error, 0)
if db.store == nil {
Expand Down

0 comments on commit 2209534

Please sign in to comment.