gitforgefs/fs/projects.go

45 lines
868 B
Go
Raw Normal View History

package fs
import (
"context"
"fmt"
"github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse"
)
type projectsNode struct {
fs.Inode
param *FSParam
rootGroupIds []int
}
// Ensure we are implementing the NodeOnAdder interface
var _ = (fs.NodeOnAdder)((*projectsNode)(nil))
2020-12-30 00:49:11 +00:00
func newProjectsNode(rootGroupIds []int, param *FSParam) *projectsNode {
return &projectsNode{
param: param,
rootGroupIds: rootGroupIds,
}
}
func (n *projectsNode) OnAdd(ctx context.Context) {
for _, groupID := range n.rootGroupIds {
2020-12-30 00:49:11 +00:00
groupNode, err := newGroupNodeByID(groupID, n.param)
if err != nil {
fmt.Printf("root group fetch fail: %v\n", err)
}
inode := n.NewPersistentInode(
ctx,
groupNode,
fs.StableAttr{
Ino: <-n.param.staticInoChan,
Mode: fuse.S_IFDIR,
},
)
2020-12-30 00:49:11 +00:00
n.AddChild(groupNode.group.Name, inode, false)
}
}