Fix db lookup for wal file

This commit is contained in:
Ben Johnson
2020-11-11 16:45:02 -07:00
parent 231b41b29f
commit bbcdb30cb3
3 changed files with 25 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
package litestream
import (
"fmt"
"log"
"os"
"path/filepath"
"sort"
"sync"
"bazil.org/fuse/fs"
@@ -71,12 +73,24 @@ func (f *FileSystem) Open() error {
// DB returns the DB object associated with path.
func (f *FileSystem) DB(path string) *DB {
fmt.Println("dbg/dbs", path, "--", f.DBPaths())
f.mu.RLock()
defer f.mu.RUnlock()
db := f.dbs[path]
return db
}
// DBPaths returns a sorted list of all paths managed by the file system.
func (f *FileSystem) DBPaths() []string {
a := make([]string, 0, len(f.dbs))
for k := range f.dbs {
a = append(a, k)
}
sort.Strings(a)
return a
}
// OpenDB initializes a DB for a given path.
func (f *FileSystem) OpenDB(path string) error {
f.mu.Lock()