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

@@ -64,9 +64,12 @@ func (n *Node) IsWAL() bool {
// DB returns the DB object associated with the node, if any.
// If node points to a "-wal" file then the associated DB is returned.
func (n *Node) DB() *DB {
if strings.HasPrefix(n.path, sqlite.WALSuffix) {
println("dbg/node.db", n.path, strings.HasPrefix(n.path, sqlite.WALSuffix))
if strings.HasSuffix(n.path, sqlite.WALSuffix) {
println("dbg/node.db.trim", n.path, strings.TrimSuffix(n.path, sqlite.WALSuffix))
return n.fs.DB(strings.TrimSuffix(n.path, sqlite.WALSuffix))
}
println("dbg/node.db.other", n.path)
return n.fs.DB(n.path)
}