MCPcopy
hub / github.com/perkeep/perkeep / newNodeFromBlobRef

Method newNodeFromBlobRef

pkg/fs/fs.go:367–385  ·  view source on GitHub ↗

consolated logic for determining a node to mount based on an arbitrary blobref

(root blob.Ref)

Source from the content-addressed store, hash-verified

365
366// consolated logic for determining a node to mount based on an arbitrary blobref
367func (fs *CamliFileSystem) newNodeFromBlobRef(root blob.Ref) (fusefs.Node, error) {
368 blob, err := fs.fetchSchemaMeta(context.TODO(), root)
369 if err != nil {
370 return nil, err
371 }
372
373 switch blob.Type() {
374 case schema.TypeDirectory:
375 n := &node{fs: fs, blobref: root, meta: blob}
376 n.populateAttr()
377 return n, nil
378
379 case schema.TypePermanode:
380 // other mutDirs listed in the default filesystem have names and are displayed
381 return &mutDir{fs: fs, permanode: root, name: "-", children: make(map[string]mutFileOrDir)}, nil
382 }
383
384 return nil, fmt.Errorf("Blobref must be of a directory or permanode got a %v", blob.Type())
385}
386
387type notImplementDirNode struct{}
388

Callers 1

NewRootedCamliFileSystemFunction · 0.80

Calls 3

fetchSchemaMetaMethod · 0.95
populateAttrMethod · 0.95
TypeMethod · 0.45

Tested by

no test coverage detected