Documentation ¶
Overview ¶
package mfs implements an in memory model of a mutable IPFS filesystem.
It consists of four main structs:
- The Filesystem The filesystem serves as a container and entry point for various mfs filesystems
- Root Root represents an individual filesystem mounted within the mfs system as a whole
- Directories
- Files
Index ¶
- Constants
- Variables
- func FlushPath(rt *Root, pth string) error
- func Mkdir(r *Root, pth string, opts MkdirOpts) error
- func Mv(r *Root, src, dst string) error
- func PutNode(r *Root, path string, nd ipld.Node) error
- type Directory
- func (d *Directory) AddChild(name string, nd ipld.Node) error
- func (d *Directory) AddUnixFSChild(name string, node ipld.Node) error
- func (d *Directory) Child(name string) (FSNode, error)
- func (d *Directory) Flush() error
- func (d *Directory) ForEachEntry(ctx context.Context, f func(NodeListing) error) error
- func (d *Directory) GetNode() (ipld.Node, error)
- func (d *Directory) GetPrefix() *cid.Prefix
- func (d *Directory) List(ctx context.Context) ([]NodeListing, error)
- func (d *Directory) ListNames(ctx context.Context) ([]string, error)
- func (d *Directory) Mkdir(name string) (*Directory, error)
- func (d *Directory) Path() string
- func (d *Directory) SetPrefix(prefix *cid.Prefix)
- func (d *Directory) Type() NodeType
- func (d *Directory) Uncache(name string)
- func (d *Directory) Unlink(name string) error
- type FSNode
- type File
- type FileDescriptor
- type MkdirOpts
- type NodeListing
- type NodeType
- type PubFunc
- type Republisher
- type Root
Constants ¶
const ( OpenReadOnly = iota OpenWriteOnly OpenReadWrite )
Variables ¶
var ErrDirExists = errors.New("directory already has entry by that name")
var ErrInvalidChild = errors.New("invalid child node")
var ErrIsDirectory = errors.New("error: is a directory")
var ErrNotExist = errors.New("no such rootfs")
var ErrNotYetImplemented = errors.New("not yet implemented")
Functions ¶
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
func NewDirectory ¶
func NewDirectory(ctx context.Context, name string, node ipld.Node, parent childCloser, dserv ipld.DAGService) (*Directory, error)
NewDirectory constructs a new MFS directory.
You probably don't want to call this directly. Instead, construct a new root using NewRoot.
func (*Directory) AddChild ¶
AddChild adds the node 'nd' under this directory giving it the name 'name'
func (*Directory) AddUnixFSChild ¶ added in v0.4.17
AddUnixFSChild adds a child to the inner UnixFS directory and transitions to a HAMT implementation if needed.
func (*Directory) ForEachEntry ¶ added in v0.4.8
type FSNode ¶
FSNode represents any node (directory, root, or file) in the mfs filesystem.
type File ¶
type File struct { RawLeaves bool // contains filtered or unexported fields }
func NewFile ¶
NewFile returns a NewFile object with the given parameters. If the Cid version is non-zero RawLeaves will be enabled.
type FileDescriptor ¶
type Republisher ¶
type Republisher struct { TimeoutLong time.Duration TimeoutShort time.Duration Publish chan struct{} // contains filtered or unexported fields }
Republisher manages when to publish a given entry.
func NewRepublisher ¶
NewRepublisher creates a new Republisher object to republish the given root using the given short and long time intervals.
func (*Republisher) Close ¶
func (p *Republisher) Close() error
func (*Republisher) Update ¶
func (np *Republisher) Update(c *cid.Cid)
Touch signals that an update has occurred since the last publish. Multiple consecutive touches may extend the time period before the next Publish occurs in order to more efficiently batch updates.
func (*Republisher) WaitPub ¶
func (p *Republisher) WaitPub()
WaitPub Returns immediately if `lastpub` value is consistent with the current value `val`, else will block until `val` has been published.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root represents the root of a filesystem tree.
func NewRoot ¶
func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf PubFunc) (*Root, error)
NewRoot creates a new Root and starts up a republisher routine for it.
func (*Root) Flush ¶
Flush signals that an update has occurred since the last publish, and updates the Root republisher.
func (*Root) FlushMemFree ¶ added in v0.4.14
FlushMemFree flushes the root directory and then uncaches all of its links. This has the effect of clearing out potentially stale references and allows them to be garbage collected. CAUTION: Take care not to ever call this while holding a reference to any child directories. Those directories will be bad references and using them may have unintended racy side effects. A better implemented mfs system (one that does smarter internal caching and refcounting) shouldnt need this method.
func (*Root) GetDirectory ¶ added in v0.4.17
GetDirectory returns the root directory.