Categorygithub.com/ipfs/go-mfs
modulepackage
0.2.2
Repository: https://github.com/ipfs/go-mfs.git
Documentation: pkg.go.dev

# README

go-mfs

go-mfs implements an in-memory model of a mutable IPFS filesystem.

standard-readme compliant GoDoc Build Status

ā— This repo is no longer maintained.

šŸ‘‰ We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/mfs. šŸŽļø Good news! There is tooling and documentation to expedite a switch in your repo.

āš ļø If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

šŸ“š Learn more, including how to take the maintainership mantle or ask questions, here.

Table of Contents

Install

go-mfs works like a regular Go module:

> go get github.com/ipfs/go-mfs

It uses Gx to manage dependencies. You can use make all to build it with the gx dependencies.

Usage

import "github.com/ipfs/go-mfs"

Check the GoDoc documentation

Documentation

Documentation around the MFS and the Files API in general around IPFS is a work in progress the following links may be of use:

Repository Structure

This repository contains many files, all belonging to the root mfs package.

  • file.go: MFS File.
  • dir.go: MFS Directory.
  • fd.go: FileDescriptor used to operate on Files.
  • ops.go: Functions that do not belong to either File nor Directory (although they mostly operate on them) that contain common operations to the MFS, e.g., find, move, add a file, make a directory.
  • root.go: MFS Root (a Directory with republishing support).
  • repub.go: Republisher.
  • mfs_test.go: General tests (needs a revision).
  • repub_test.go: Republisher-specific tests (contains only the TestRepublisher function).

License

MIT Ā© Protocol Labs, Inc.

# Functions

DirLookup will look up a file or directory at the given path under the directory 'd' Deprecated: use github.com/ipfs/boxo/mfs.DirLookup.
TODO: Document this function and link its functionality with the republisher.
IsDir checks whether the FSNode is dir type Deprecated: use github.com/ipfs/boxo/mfs.IsDir.
IsFile checks whether the FSNode is file type Deprecated: use github.com/ipfs/boxo/mfs.IsFile.
Lookup extracts the root directory and performs a lookup under it.
Mkdir creates a directory at 'path' under the directory 'd', creating intermediary directories as needed if 'mkparents' is set to true Deprecated: use github.com/ipfs/boxo/mfs.Mkdir.
Mv moves the file or directory at 'src' to 'dst' TODO: Document what the strings 'src' and 'dst' represent.
NewDirectory constructs a new MFS directory.
NewFile returns a NewFile object with the given parameters.
NewRepublisher creates a new Republisher object to republish the given root using the given short and long time intervals.
NewRoot creates a new Root and starts up a republisher routine for it.
PutNode inserts 'nd' at 'path' in the given mfs TODO: Rename or clearly document that this is not about nodes but actually MFS files/directories (that in the underlying representation can be considered as just nodes).

# Constants

Deprecated: use github.com/ipfs/boxo/mfs.TDir.
Deprecated: use github.com/ipfs/boxo/mfs.TFile.

# Variables

Deprecated: use github.com/ipfs/boxo/mfs.ErrClosed.
Deprecated: use github.com/ipfs/boxo/mfs.ErrDirExists.
Deprecated: use github.com/ipfs/boxo/mfs.ErrInvalidChild.
TODO: Remove if not used.
TODO: Remove if not used.
Deprecated: use github.com/ipfs/boxo/mfs.ErrNotYetImplemented.

# Structs

TODO: There's too much functionality associated with this structure, let's organize it (and if possible extract part of it elsewhere) and document the main features of `Directory` here.
File represents a file in the MFS, its logic its mainly targeted to coordinating (potentially many) `FileDescriptor`s pointing to it.
Deprecated: use github.com/ipfs/boxo/mfs.Flags.
MkdirOpts is used by Mkdir Deprecated: use github.com/ipfs/boxo/mfs.MkdirOpts.
Deprecated: use github.com/ipfs/boxo/mfs.NodeListing.
Republisher manages when to publish a given entry.
Root represents the root of a filesystem tree.

# Interfaces

One `File` can have many `FileDescriptor`s associated to it (only one if it's RW, many if they are RO, see `File.desclock`).
FSNode abstracts the `Directory` and `File` structures, it represents any child node in the MFS (i.e., all the nodes besides the `Root`).

# Type aliases

Deprecated: use github.com/ipfs/boxo/mfs.NodeType.
PubFunc is the user-defined function that determines exactly what logic entails "publishing" a `Cid` value.