diff --git a/pkg/fs/fs.go b/pkg/fs/fs.go index c2d740365..45bc46595 100644 --- a/pkg/fs/fs.go +++ b/pkg/fs/fs.go @@ -264,13 +264,13 @@ func (n *node) ReadDir(intr fuse.Intr) ([]fuse.Dirent, fuse.Error) { ssc = append(ssc, ch) // TODO: move the cmd/camput/chanworker.go into its own package, and use it here. only // have 10 or so of these loading at once. for now we do them all. - go func() { + go func(memberRef *blobref.BlobRef) { mss, err := n.fs.fetchSchemaMeta(memberRef) if err != nil { log.Printf("error reading entry %v in readdir: %v", memberRef, err) } ch <- res{memberRef, mss, err} - }() + }(memberRef) } n.dirents = make([]fuse.Dirent, 0) diff --git a/pkg/fs/recent.go b/pkg/fs/recent.go index b18439b93..6c0895741 100644 --- a/pkg/fs/recent.go +++ b/pkg/fs/recent.go @@ -71,10 +71,18 @@ func (n *recentDir) ReadDir(intr fuse.Intr) ([]fuse.Dirent, fuse.Error) { continue } ccMeta := res.Meta.Get(cc) - if ccMeta == nil || ccMeta.File == nil { // TODO: also allow directories + if ccMeta == nil { + continue + } + var name string + switch { + case ccMeta.File != nil: + name = ccMeta.File.FileName + case ccMeta.Dir != nil: + name = ccMeta.Dir.FileName + default: continue } - name := ccMeta.File.FileName if name == "" || n.ents[name] != nil { name = ccMeta.BlobRef.String() + path.Ext(name) if n.ents[name] != nil { @@ -94,6 +102,13 @@ func (n *recentDir) ReadDir(intr fuse.Intr) ([]fuse.Dirent, fuse.Error) { func (n *recentDir) Lookup(name string, intr fuse.Intr) (fuse.Node, fuse.Error) { n.mu.Lock() defer n.mu.Unlock() + if n.ents == nil { + // Odd case: a Lookup before a Readdir. Force a readdir to + // seed our map. Mostly hit just during development. + n.mu.Unlock() // release, since ReadDir will acquire + n.ReadDir(intr) + n.mu.Lock() + } db := n.ents[name] log.Printf("fs.recent: Lookup(%q) = %v", name, db) if db == nil {