remove staticInoChan, as it's redundant
This commit is contained in:
parent
3e84321e85
commit
2dc97f1672
|
@ -23,7 +23,7 @@ var _ = (fs.NodeOpener)((*refreshNode)(nil))
|
||||||
|
|
||||||
func newRefreshNode(source GroupSource, param *FSParam) *refreshNode {
|
func newRefreshNode(source GroupSource, param *FSParam) *refreshNode {
|
||||||
return &refreshNode{
|
return &refreshNode{
|
||||||
ino: <-param.staticInoChan,
|
ino: 0,
|
||||||
source: source,
|
source: source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@ import (
|
||||||
"github.com/hanwen/go-fuse/v2/fuse"
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
staticInodeStart = uint64(int(^(uint(0))>>1)) + 1
|
|
||||||
)
|
|
||||||
|
|
||||||
type staticNode interface {
|
type staticNode interface {
|
||||||
fs.InodeEmbedder
|
fs.InodeEmbedder
|
||||||
Ino() uint64
|
Ino() uint64
|
||||||
|
@ -35,8 +31,7 @@ type FSParam struct {
|
||||||
GitClient GitClient
|
GitClient GitClient
|
||||||
GitForge GitForge
|
GitForge GitForge
|
||||||
|
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
staticInoChan chan uint64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type rootNode struct {
|
type rootNode struct {
|
||||||
|
@ -54,13 +49,10 @@ func Start(logger *slog.Logger, mountpoint string, mountoptions []string, param
|
||||||
opts.Debug = debug
|
opts.Debug = debug
|
||||||
|
|
||||||
param.logger = logger
|
param.logger = logger
|
||||||
param.staticInoChan = make(chan uint64)
|
|
||||||
root := &rootNode{
|
root := &rootNode{
|
||||||
param: param,
|
param: param,
|
||||||
}
|
}
|
||||||
|
|
||||||
go staticInoGenerator(root.param.staticInoChan)
|
|
||||||
|
|
||||||
server, err := fs.Mount(mountpoint, root, opts)
|
server, err := fs.Mount(mountpoint, root, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("mount failed: %v", err)
|
return fmt.Errorf("mount failed: %v", err)
|
||||||
|
@ -88,7 +80,7 @@ func (n *rootNode) OnAdd(ctx context.Context) {
|
||||||
ctx,
|
ctx,
|
||||||
groupNode,
|
groupNode,
|
||||||
fs.StableAttr{
|
fs.StableAttr{
|
||||||
Ino: <-n.param.staticInoChan,
|
Ino: 0,
|
||||||
Mode: fuse.S_IFDIR,
|
Mode: fuse.S_IFDIR,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -98,14 +90,6 @@ func (n *rootNode) OnAdd(ctx context.Context) {
|
||||||
n.param.logger.Info("Mounted and ready to use")
|
n.param.logger.Info("Mounted and ready to use")
|
||||||
}
|
}
|
||||||
|
|
||||||
func staticInoGenerator(staticInoChan chan<- uint64) {
|
|
||||||
i := staticInodeStart
|
|
||||||
for {
|
|
||||||
staticInoChan <- i
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func signalHandler(logger *slog.Logger, signalChan <-chan os.Signal, server *fuse.Server) {
|
func signalHandler(logger *slog.Logger, signalChan <-chan os.Signal, server *fuse.Server) {
|
||||||
err := server.WaitMount()
|
err := server.WaitMount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue