Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show position file in readdir output #175

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fuse/file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions fuse/root_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand All @@ -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,
})
}
Expand Down