Skip to content
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
27 changes: 4 additions & 23 deletions internal/mountfuse/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (n *DirNode) Getattr(ctx context.Context, _ gofusefs.FileHandle, out *fuse.
}

func (n *DirNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*gofusefs.Inode, syscall.Errno) {
if child := n.lookupCachedChild(name); child != nil {
if child := n.GetChild(name); child != nil {
if existing, ok := child.Operations().(interface {
fillEntry(*fuse.EntryOut) syscall.Errno
}); ok {
Expand All @@ -67,6 +67,7 @@ func (n *DirNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (
if err != nil {
return nil, readErrno(err)
}
// Alias directories traverse through the same lookup path as any other child.
meta, _, ok := resolveDirectoryEntry(entries, name)
if !ok {
out.SetEntryTimeout(n.state.negativeTTL)
Expand Down Expand Up @@ -135,7 +136,7 @@ func (n *DirNode) Unlink(ctx context.Context, name string) syscall.Errno {
if err != nil {
return writeErrno(err)
}
meta, resolvedName, ok := resolveDirectoryEntry(entries, name)
meta, _, ok := resolveDirectoryEntry(entries, name)
if !ok {
return syscall.ENOENT
}
Expand All @@ -154,11 +155,7 @@ func (n *DirNode) Unlink(ctx context.Context, name string) syscall.Errno {
return writeErrno(err)
}
n.state.invalidate(meta.path)
if resolvedName == name || n.GetChild(name) == nil {
n.RmChild(resolvedName)
return 0
}
n.RmChild(resolvedName, name)
n.RmChild(name)
return 0
}

Expand All @@ -171,19 +168,3 @@ func (n *DirNode) fillEntry(out *fuse.EntryOut) syscall.Errno {
meta.fillEntry(out, n.state)
return 0
}

func (n *DirNode) lookupCachedChild(name string) *gofusefs.Inode {
if child := n.GetChild(name); child != nil {
return child
}
children := n.Children()
names := make([]string, 0, len(children))
for childName := range children {
names = append(names, childName)
}
resolvedName, ok := resolveNameByID(names, name)
if !ok {
return nil
}
return n.GetChild(resolvedName)
}
9 changes: 8 additions & 1 deletion internal/mountfuse/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ func (s *fsState) listDirectory(ctx context.Context, remotePath string) (map[str
entries[meta.name] = meta
}
if remotePath == s.remoteRoot {
// Alias directories such as by-title/by-id are adapter-owned remote
// entries; the only synthesized root entry here is the virtual layout.
entries[layoutFilename] = virtualLayoutMeta(s.remoteRoot)
}
s.putDir(remotePath, entries)
Expand Down Expand Up @@ -413,8 +415,13 @@ func (s *fsState) treeEntryToMeta(entry mountsync.TreeEntry, parentPath string)
return nodeMeta{}, false
}
mode := uint32(syscall.S_IFREG | defaultFileMode)
if strings.EqualFold(entry.Type, "directory") || strings.EqualFold(entry.Type, "dir") {
switch {
case strings.EqualFold(entry.Type, "directory"), strings.EqualFold(entry.Type, "dir"):
mode = syscall.S_IFDIR | defaultDirMode
case strings.EqualFold(entry.Type, "symlink"):
// Forward compatibility: if a future adapter emits symlink-like alias
// entries, surface them as readable files and let lazy reads populate
// size/revision details from ReadFile.
}
return nodeMeta{
path: childPath,
Expand Down
Loading
Loading