consolated logic for determining a node to mount based on an arbitrary blobref
(root blob.Ref)
| 365 | |
| 366 | // consolated logic for determining a node to mount based on an arbitrary blobref |
| 367 | func (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 | |
| 387 | type notImplementDirNode struct{} |
| 388 |
no test coverage detected