diff --git a/db.go b/db.go index 538a292..4d951f0 100644 --- a/db.go +++ b/db.go @@ -244,7 +244,13 @@ func (db *DB) shadowWALExists() (bool, error) { // contents of the database page. func (db *DB) recoverShadowWALOnly() error { db.logger.Printf("recovering: shadow WAL only") - panic("TODO") + + // TODO: Verify last page in shadow WAL matches data in DB. + + db.processedWALByteN = 0 + db.pendingWALByteN = 0 + + return nil } // recoverRealAndShadowWALs verifies the last page of the real & shadow WALs match. diff --git a/file_system.go b/file_system.go index 577b39f..be1ab37 100644 --- a/file_system.go +++ b/file_system.go @@ -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() diff --git a/node.go b/node.go index 4672bfe..5dabfe8 100644 --- a/node.go +++ b/node.go @@ -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) }