gitforgefs/fstree/repository.go

50 lines
1.0 KiB
Go
Raw Normal View History

package fstree
import (
"context"
"syscall"
"github.com/hanwen/go-fuse/v2/fs"
)
2024-08-09 20:34:45 +00:00
const (
repositoryBaseInode = 2_000_000_000
)
type repositoryNode struct {
fs.Inode
param *FSParam
source RepositorySource
}
type RepositorySource interface {
// GetName() string
GetRepositoryID() uint64
GetCloneURL() string
GetDefaultBranch() string
}
// Ensure we are implementing the NodeReaddirer interface
var _ = (fs.NodeReadlinker)((*repositoryNode)(nil))
func newRepositoryNodeFromSource(source RepositorySource, param *FSParam) (*repositoryNode, error) {
node := &repositoryNode{
param: param,
source: source,
}
2020-12-29 02:37:18 +00:00
// Passthrough the error if there is one, nothing to add here
// Errors on clone/pull are non-fatal
return node, nil
}
func (n *repositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
2020-12-29 02:37:18 +00:00
// Create the local copy of the repo
// TODO: cleanup
localRepositoryPath, err := n.param.GitClient.FetchLocalRepositoryPath(n.source)
if err != nil {
2024-06-06 05:51:34 +00:00
n.param.logger.Error(err.Error())
}
return []byte(localRepositoryPath), 0
}