gitforgefs/fs/refresh.go

47 lines
1.0 KiB
Go
Raw Permalink Normal View History

2020-12-31 20:00:10 +00:00
package fs
import (
"context"
"syscall"
"github.com/badjware/gitlabfs/gitlab"
"github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse"
)
type refreshNode struct {
fs.Inode
ino uint64
refresher gitlab.Refresher
}
// Ensure we are implementing the NodeSetattrer interface
var _ = (fs.NodeSetattrer)((*refreshNode)(nil))
// Ensure we are implementing the NodeOpener interface
var _ = (fs.NodeOpener)((*refreshNode)(nil))
func newRefreshNode(refresher gitlab.Refresher, param *FSParam) *refreshNode {
return &refreshNode{
ino: <-param.staticInoChan,
refresher: refresher,
}
}
func (n *refreshNode) Ino() uint64 {
return n.ino
}
func (n *refreshNode) Mode() uint32 {
return fuse.S_IFREG
}
func (n *refreshNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
return 0
}
func (n *refreshNode) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
n.refresher.InvalidateCache()
return nil, 0, 0
}