From 1eb00817944b32f340c16fdc6782123db7274788 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sat, 12 Nov 2022 11:03:58 -0700 Subject: [PATCH] Show position file in readdir output --- fuse/file_system_test.go | 6 +++--- fuse/root_node.go | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fuse/file_system_test.go b/fuse/file_system_test.go index 433b94c..3d439cf 100644 --- a/fuse/file_system_test.go +++ b/fuse/file_system_test.go @@ -315,11 +315,11 @@ func TestFileSystem_ReadDir(t *testing.T) { var want string switch testingutil.JournalMode() { case "wal": - want = "db0\ndb0-shm\ndb0-wal\ndb1\ndb1-shm\ndb1-wal\n" + want = "db0\ndb0-pos\ndb0-shm\ndb0-wal\ndb1\ndb1-pos\ndb1-shm\ndb1-wal\n" case "persist", "truncate": - want = "db0\ndb0-journal\ndb1\ndb1-journal\n" + want = "db0\ndb0-journal\ndb0-pos\ndb1\ndb1-journal\ndb1-pos\n" default: - want = "db0\ndb1\n" + want = "db0\ndb0-pos\ndb1\ndb1-pos\n" } // Read directory listing from mount. diff --git a/fuse/root_node.go b/fuse/root_node.go index 0a13335..3c895c4 100644 --- a/fuse/root_node.go +++ b/fuse/root_node.go @@ -349,9 +349,14 @@ func (h *RootHandle) ReadDirAll(ctx context.Context) (ents []fuse.Dirent, err er Type: fuse.DT_File, }) - if _, err := os.Stat(db.WALPath()); err == nil { + ents = append(ents, fuse.Dirent{ + Name: db.Name() + "-pos", + Type: fuse.DT_File, + }) + + if _, err := os.Stat(db.JournalPath()); err == nil { ents = append(ents, fuse.Dirent{ - Name: fmt.Sprintf("%s-wal", db.Name()), + Name: fmt.Sprintf("%s-journal", db.Name()), Type: fuse.DT_File, }) } @@ -361,9 +366,9 @@ func (h *RootHandle) ReadDirAll(ctx context.Context) (ents []fuse.Dirent, err er Type: fuse.DT_File, }) } - if _, err := os.Stat(db.JournalPath()); err == nil { + if _, err := os.Stat(db.WALPath()); err == nil { ents = append(ents, fuse.Dirent{ - Name: fmt.Sprintf("%s-journal", db.Name()), + Name: fmt.Sprintf("%s-wal", db.Name()), Type: fuse.DT_File, }) }