local

package
v2.6.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Skip skips the path merge.
	Skip MergeStrategy = "Skip"
	// Merge attempts to merge the paths (directories only).
	Merge = "Merge"
	// Replace replaces the old path with the new path.
	Replace = "Replace"
)

Variables

View Source
var (
	// ErrUpToDate indicates there are no locally staged changes.
	ErrUpToDate = errors.New("everything up-to-date")
	// ErrAborted indicates the caller aborted the operation via a confirm function.
	ErrAborted = errors.New("operation aborted by caller")
)
View Source
var (
	// ErrNotABucket indicates the given path is not within a bucket.
	ErrNotABucket = errors.New("not a bucket (or any of the parent directories): .textile")
	// ErrBucketExists is used during initialization to indicate the path already contains a bucket.
	ErrBucketExists = errors.New("bucket is already initialized")
	// ErrThreadRequired indicates the operation requires a thread ID but none was given.
	ErrThreadRequired = errors.New("thread ID is required")
)
View Source
var MaxPullConcurrency = 10

MaxPullConcurrency is the maximum number of files that can be pulled concurrently.

View Source
var (
	// PatchExt is used to ignore tmp files during a pull.
	PatchExt = ".buckpatch"
)

Functions

func ChangeColor

func ChangeColor(t du.ChangeType) func(arg interface{}) aurora2.Value

ChangeColor returns an appropriate color for the given change type.

func ChangeType

func ChangeType(t du.ChangeType) string

ChangeType returns a string representation of a change type.

func DefaultConfConfig

func DefaultConfConfig() cmd.ConfConfig

DefaultConfConfig returns the default ConfConfig.

func Diff

func Diff(ctx context.Context, ds ipld.DAGService, a, b ipld.Node) ([]*du.Change, error)

Diff returns a set of changes that transform node 'a' into node 'b'. Modified from https://github.com/ipfs/go-merkledag/blob/master/dagutils/diff.go#L104 It only traverses links in the following cases: 1. two node's links number are greater than 0. 2. both of two nodes are ProtoNode. 3. neither of the nodes is a file node, which contains only unnamed raw blocks Otherwise, it compares the cid and emits a Mod change object.

func Ignore

func Ignore(pth string, ig *ignore.GitIgnore) bool

Ignore returns true if the path contains an ignored file.

func IgnoreFile added in v2.6.13

func IgnoreFile(pth string) (*ignore.GitIgnore, error)

IgnoreFile returns the ignore file at path if it exists

Types

type AddOption

type AddOption func(*addOptions)

AddOption is used when staging a remote Unixfs dag cid in a local bucket.

func WithAddEvents

func WithAddEvents(ch chan<- Event) AddOption

WithAddEvents allows the caller to receive events when staging files from a remote Unixfs dag.

func WithSelectMerge

func WithSelectMerge(f SelectMergeFunc) AddOption

WithSelectMerge allows the caller to select the path merge strategy.

type Archive

type Archive struct {
	Cid   string `json:"cid"`
	Deals []Deal `json:"deals"`
}

Archive is a single Filecoin archive containing a list of deals.

type ArchiveConfig added in v2.1.0

type ArchiveConfig struct {
	// RepFactor (ignored in Filecoin mainnet) indicates the desired amount of active deals
	// with different miners to store the data. While making deals
	// the other attributes of FilConfig are considered for miner selection.
	RepFactor int `json:"repFactor"`
	// DealMinDuration indicates the duration to be used when making new deals.
	DealMinDuration int64 `json:"dealMinDuration"`
	// ExcludedMiners (ignored in Filecoin mainnet) is a set of miner addresses won't be ever be selected
	// when making new deals, even if they comply to other filters.
	ExcludedMiners []string `json:"excludedMiners"`
	// TrustedMiners (ignored in Filecoin mainnet) is a set of miner addresses which will be forcibly used
	// when making new deals. An empty/nil list disables this feature.
	TrustedMiners []string `json:"trustedMiners"`
	// CountryCodes (ignored in Filecoin mainnet) indicates that new deals should select miners on specific
	// countries.
	CountryCodes []string `json:"countryCodes"`
	// Renew indicates deal-renewal configuration.
	Renew ArchiveRenew `json:"renew"`
	// MaxPrice is the maximum price that will be spent to store the data
	MaxPrice uint64 `json:"maxPrice"`
	// FastRetrieval indicates that created deals should enable the
	// fast retrieval feature.
	FastRetrieval bool `json:"fastRetrieval"`
	// DealStartOffset indicates how many epochs in the future impose a
	// deadline to new deals being active on-chain. This value might influence
	// if miners accept deals, since they should seal fast enough to satisfy
	// this constraint.
	DealStartOffset int64 `json:"dealStartOffset"`
	// verifiedDeal indicates that new deals will be verified-deals, using
	// available data-cap from the wallet address.
	VerifiedDeal bool `json:"verifiedDeal"`
}

ArchiveConfig is the desired state of a Cid in the Filecoin network.

type ArchiveMessageType

type ArchiveMessageType int

ArchiveMessageType is the type of status message.

const (
	// ArchiveMessage accompanies an informational message.
	ArchiveMessage ArchiveMessageType = iota
	// ArchiveError accompanies an error state.
	ArchiveError
)

type ArchiveRemoteOption added in v2.1.0

type ArchiveRemoteOption func(*archiveRemoteOptions)

func WithArchiveConfig added in v2.1.0

func WithArchiveConfig(config ArchiveConfig) ArchiveRemoteOption

WithArchiveConfig allows you to provide a custom ArchiveConfig for a single call to ArchiveRemote.

func WithSkipAutomaticVerifiedDeal added in v2.6.5

func WithSkipAutomaticVerifiedDeal(enabled bool) ArchiveRemoteOption

WithSkipAutomaticVerifiedDeal allows to skip backend logic to automatically set the verified deal flag for making the archive.

type ArchiveRenew added in v2.1.0

type ArchiveRenew struct {
	// Enabled indicates that deal-renewal is enabled for this Cid.
	Enabled bool `json:"enabled"`
	// Threshold indicates how many epochs before expiring should trigger
	// deal renewal. e.g: 100 epoch before expiring.
	Threshold int `json:"threshold"`
}

ArchiveRenew contains renew configuration for a ArchiveConfig.

type ArchiveStatusMessage

type ArchiveStatusMessage struct {
	Type            ArchiveMessageType
	Message         string
	Error           error
	InactivityClose bool
}

ArchiveStatusMessage is used to wrap an archive status message.

type Archives added in v2.6.0

type Archives struct {
	Current Archive   `json:"current"`
	History []Archive `json:"history,omitempty"`
}

Archives contains info about bucket Filecoin archives.

type AuthFunc

type AuthFunc func(context.Context) context.Context

AuthFunc is a function that's used to add additional context information to the outgoing API requests.

type Bucket

type Bucket struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Bucket is a local-first object storage and synchronization model built on ThreadDB, IPFS, and Filecoin. A bucket represents a dynamic Unixfs directory with auto-updating IPNS resolution, website rendering, and Filecoin archivng.

Private buckets are fully encrypted using AES-CTR + AES-512 HMAC (see https://github.com/textileio/dcrypto for more). Both Unixfs node metadata (size, links, etc.) and node data (files) are obfuscated by encryption. The AES and HMAC keys used for bucket encryption are stored in the ThreadDB collection instance. This setup allows for bucket access to inherit from thread ACL rules.

Additionally, files can be further protected by password-based encryption before they are added to the bucket. See EncryptLocalPath and DecryptLocalPath for more.

func (*Bucket) AddRemoteCid

func (b *Bucket) AddRemoteCid(ctx context.Context, c cid.Cid, dest string, opts ...AddOption) error

AddRemoteCid stages the Unixfs dag at cid in the local bucket, optionally allowing the caller to select a merge strategy.

func (*Bucket) AddRemoteFiles added in v2.6.10

func (b *Bucket) AddRemoteFiles(
	ctx context.Context,
	key string,
	xroot path.Resolved,
	changes []Change,
	force bool,
	events chan<- Event,
) (root path.Resolved, err error)

AddRemoteFiles applies "add" and "modify" changes to a remote bucket. See PathOption for more info.

func (*Bucket) Addresses added in v2.6.5

func (b *Bucket) Addresses(ctx context.Context) (*powPb.AddressesResponse, error)

Addresses returns information about the Filecoin address associated with the account.

func (*Bucket) ArchiveRemote

func (b *Bucket) ArchiveRemote(ctx context.Context, opts ...ArchiveRemoteOption) error

ArchiveRemote requests an archive of the current remote bucket.

func (*Bucket) ArchiveWatch added in v2.2.0

func (b *Bucket) ArchiveWatch(ctx context.Context) (<-chan ArchiveStatusMessage, error)

ArchiveWatch delivers messages about the archive status.

func (*Bucket) Archives added in v2.2.0

func (b *Bucket) Archives(ctx context.Context) (*pb.ArchivesResponse, error)

Archives returns information about current and historical archives.

func (*Bucket) CatRemotePath

func (b *Bucket) CatRemotePath(ctx context.Context, pth string, w io.Writer) error

CatRemotePath writes the content of the remote path to writer.

func (*Bucket) ConfDir added in v2.6.10

func (b *Bucket) ConfDir() string

ConfDir returns the bucket's local configuration directory path.

func (*Bucket) Context added in v2.6.10

func (b *Bucket) Context(ctx context.Context) (context.Context, error)

Context returns an authorized context for the bucket.

func (*Bucket) Cwd added in v2.6.10

func (b *Bucket) Cwd() string

Cwd returns the bucket's local current working directory.

func (*Bucket) DBInfo

func (b *Bucket) DBInfo(ctx context.Context) (info db.Info, cc db.CollectionConfig, err error)

DBInfo returns info about the bucket's ThreadDB. This info can be used to add replicas or additional peers to the bucket.

func (*Bucket) DecryptLocalPath

func (b *Bucket) DecryptLocalPath(pth string, key []byte, w io.Writer) error

DecryptLocalPath decrypts the file at path with key, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC.

func (*Bucket) DecryptLocalPathWithPassword

func (b *Bucket) DecryptLocalPathWithPassword(pth, password string, w io.Writer) error

DecryptLocalPathWithPassword decrypts the file at path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.

func (*Bucket) DecryptRemotePath

func (b *Bucket) DecryptRemotePath(ctx context.Context, pth string, key []byte, w io.Writer) error

DecryptRemotePath decrypts the file at the remote path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC.

func (*Bucket) DecryptRemotePathWithPassword

func (b *Bucket) DecryptRemotePathWithPassword(ctx context.Context, pth, password string, w io.Writer) error

DecryptRemotePathWithPassword decrypts the file at the remote path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.

func (*Bucket) DefaultArchiveConfig added in v2.1.0

func (b *Bucket) DefaultArchiveConfig(ctx context.Context) (config ArchiveConfig, err error)

DefaultArchiveConfig gets the default archive config for the specified Bucket.

func (*Bucket) Destroy

func (b *Bucket) Destroy(ctx context.Context) error

Destroy completely deletes the local and remote bucket.

func (*Bucket) DiffLocal

func (b *Bucket) DiffLocal() ([]Change, error)

DiffLocal returns a list of locally staged bucket file changes.

func (*Bucket) EncryptLocalPath

func (b *Bucket) EncryptLocalPath(pth string, key []byte, w io.Writer) error

EncryptLocalPath encrypts the file at path with key, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC.

func (*Bucket) EncryptLocalPathWithPassword

func (b *Bucket) EncryptLocalPathWithPassword(pth, password string, w io.Writer) error

EncryptLocalPathWithPassword encrypts the file at path with password, writing the result to the writer. Encryption is AES-CTR + AES-512 HMAC. https://godoc.org/golang.org/x/crypto/scrypt is used to derive the keys from the password.

func (*Bucket) Info

func (b *Bucket) Info(ctx context.Context) (info Info, err error)

Info returns info about a bucket from the remote.

func (*Bucket) Key

func (b *Bucket) Key() string

Key returns the bucket's unique key identifier, which is also an IPNS public key.

func (*Bucket) ListRemotePath

func (b *Bucket) ListRemotePath(ctx context.Context, pth string) (items []BucketItem, err error)

ListRemotePath returns a list of all bucket items under path.

func (*Bucket) LocalSize

func (b *Bucket) LocalSize() (int64, error)

LocalSize returns the cumalative size of the bucket's local files.

func (*Bucket) Path

func (b *Bucket) Path() (string, error)

Path returns the bucket's top-level local filesystem path.

func (*Bucket) PullPathAccessRoles

func (b *Bucket) PullPathAccessRoles(ctx context.Context, pth string) (roles map[string]buckets.Role, err error)

PullPathAccessRoles returns access roles for a path.

func (*Bucket) PullRemote

func (b *Bucket) PullRemote(ctx context.Context, opts ...PathOption) (roots Roots, err error)

PullRemote pulls remote files. By default, only missing files are pulled. See PathOption for more info.

func (*Bucket) PushLocal

func (b *Bucket) PushLocal(ctx context.Context, opts ...PathOption) (roots Roots, err error)

PushLocal pushes local files. By default, only staged changes are pushed. See PathOption for more info.

func (*Bucket) PushPathAccessRoles

func (b *Bucket) PushPathAccessRoles(
	ctx context.Context,
	pth string,
	roles map[string]buckets.Role,
) (merged map[string]buckets.Role, err error)

PushPathAccessRoles updates path access roles by merging the pushed roles with existing roles and returns the merged roles. roles is a map of string marshaled public keys to path roles. A non-nil error is returned if the map keys are not unmarshalable to public keys. To delete a role for a public key, set its value to buckets.None.

func (b *Bucket) RemoteLinks(ctx context.Context, pth string) (links Links, err error)

RemoteLinks returns the remote links for the bucket.

func (*Bucket) RemoveRemoteFile added in v2.6.10

func (b *Bucket) RemoveRemoteFile(
	ctx context.Context,
	key string,
	xroot path.Resolved,
	c Change,
	force bool,
	events chan<- Event,
) (path.Resolved, error)

RemoveRemoteFile applies a "remove" change to a remote bucket. See PathOption for more info.

func (*Bucket) RetrievalID added in v2.6.0

func (b *Bucket) RetrievalID() string

RetrievalID returns the retrieval-id if the bucket creation was bootstrapped from a Filecoin archive. It only has a non-empty value in this use-case.

func (*Bucket) Roots

func (b *Bucket) Roots(ctx context.Context) (roots Roots, err error)

Roots returns the bucket's current local and remote root cids.

func (*Bucket) SendPathInvite

func (b *Bucket) SendPathInvite(ctx context.Context, from thread.Identity, to thread.PubKey, pth string) error

SendPathInvite sends a message containing a bucket key and path, which can be used to access a shared file / folder.

func (*Bucket) SetDefaultArchiveConfig added in v2.1.0

func (b *Bucket) SetDefaultArchiveConfig(ctx context.Context, config ArchiveConfig) (err error)

SetDefaultArchiveConfig sets the default archive config for the specified Bucket.

func (*Bucket) Thread

func (b *Bucket) Thread() (id thread.ID, err error)

Thread returns the bucket's thread ID.

func (*Bucket) Watch

func (b *Bucket) Watch(ctx context.Context, opts ...WatchOption) (<-chan cmd.WatchState, error)

Watch watches for and auto-pushes local bucket changes at an interval, and listens for and auto-pulls remote changes as they arrive. Use the WithOffline option to keep watching during network interruptions. Returns a channel of watch connectivity states. Cancel context to stop watching.

type BucketItem

type BucketItem struct {
	Cid        cid.Cid      `json:"cid"`
	Name       string       `json:"name"`
	Path       string       `json:"path"`
	Size       int64        `json:"size"`
	IsDir      bool         `json:"is_dir"`
	Items      []BucketItem `json:"items"`
	ItemsCount int          `json:"items_count"`
}

BucketItem describes an item (file/directory) in a bucket.

type Buckets

type Buckets struct {
	// contains filtered or unexported fields
}

Buckets is used to create new individual buckets based on the provided clients and config.

func NewBuckets

func NewBuckets(clients *cmd.Clients, config cmd.ConfConfig) *Buckets

NewBuckets creates Buckets from clients and config.

func NewBucketsWithAuth

func NewBucketsWithAuth(clients *cmd.Clients, config cmd.ConfConfig, auth AuthFunc) *Buckets

NewBucketsWithAuth creates Buckets from clients and config and auth.

func (*Buckets) Clients

func (b *Buckets) Clients() *cmd.Clients

Clients returns the underlying clients object.

func (*Buckets) Context

func (b *Buckets) Context(ctx context.Context) context.Context

Context gets a context wrapped with auth if it exists.

func (*Buckets) GetLocalBucket

func (b *Buckets) GetLocalBucket(ctx context.Context, conf Config) (*Bucket, error)

GetLocalBucket loads and returns the bucket at path if it exists.

func (*Buckets) NewBucket

func (b *Buckets) NewBucket(ctx context.Context, conf Config, opts ...NewOption) (buck *Bucket, err error)

NewBucket initializes a new bucket from the config. A local blockstore is created that's used to sync local changes with the remote. By default, this will be an unencrypted, unnamed, empty bucket. The remote bucket will also be created if it doesn't already exist. See NewOption for more info. If the Unfreeze flag is set, the bucket gets created async thus `*Bucket` return value will nil (i.e: the method return will be (nil, nil))

func (*Buckets) NewConfigFromCmd

func (b *Buckets) NewConfigFromCmd(c *cobra.Command, pth string) (conf Config, err error)

NewConfigFromCmd returns a config by inflating values from the given cobra command and path. First, flags for "key" and "thread" are used if they exist. If still unset, the env vars {EnvPrefix}_KEY and {EnvPrefix}_THREAD are used.

func (*Buckets) RemoteBuckets

func (b *Buckets) RemoteBuckets(ctx context.Context, id thread.ID) (list []Info, err error)

RemoteBuckets lists all existing remote buckets in the thread. If id is not defined, this will return buckets from all threads. In a hub context, this will only list buckets that the context has access to.

type Change

type Change struct {
	Type du.ChangeType
	Name string // Absolute file name
	Path string // File name relative to the bucket root
	Rel  string // File name relative to the bucket current working directory
}

Change describes a local bucket change.

type Config

type Config struct {
	// Path is the path in which the new bucket should be created (required).
	Path string
	// Key is a key of an existing bucket (optional).
	// It's value may be inflated from a --key flag or {EnvPrefix}_KEY env variable.
	Key string
	// Thread is the thread ID of the target thread (required).
	// It's value may be inflated from a --thread flag or {EnvPrefix}_THREAD env variable.
	Thread thread.ID
}

Config contains details for a new local bucket.

type ConfirmDiffFunc

type ConfirmDiffFunc func([]Change) bool

ConfirmDiffFunc is a caller-provided function which presents a list of bucket changes.

type Deal added in v2.6.0

type Deal struct {
	ProposalCid string `json:"proposal_cid"`
	Miner       string `json:"miner"`
}

Deal contains info about an archive's Filecoin deal.

type Event added in v2.6.0

type Event struct {
	// Type of event.
	Type EventType
	// Path relative to the bucket's cwd.
	Path string
	// Cid of associated Path.
	Cid cid.Cid
	// Size of the total operation or completed file.
	Size int64
	// Complete is the amount of Size that is complete (useful for upload/download progress).
	Complete int64
}

Event describes a path event that occurred. These events can be used to display live info during path uploads/downloads.

type EventType added in v2.6.0

type EventType int

EventType is the type of path event.

const (
	// EventProgress indicates a file has made some progress uploading/downloading.
	EventProgress EventType = iota
	// EventFileComplete indicates a file has completed uploading/downloading.
	EventFileComplete
	// EventFileRemoved indicates a file has been removed.
	EventFileRemoved
)

type Info

type Info struct {
	Thread    thread.ID           `json:"thread"`
	Key       string              `json:"key"`
	Owner     string              `json:"owner,omitempty"`
	Name      string              `json:"name,omitempty"`
	Version   int                 `json:"version"`
	LinkKey   string              `json:"link_key,omitempty"`
	Path      Path                `json:"path"`
	Metadata  map[string]Metadata `json:"metadata,omitempty"`
	Archives  *Archives           `json:"archives,omitempty"`
	CreatedAt time.Time           `json:"created_at"`
	UpdatedAt time.Time           `json:"updated_at"`
}

Info wraps info about a bucket.

type InitStrategy added in v2.5.0

type InitStrategy int

InitStrategy describes the type of init strategy.

const (
	// Hybrid indicates locally staged changes should be accepted, excluding deletions.
	Hybrid InitStrategy = iota
	// Soft indicates locally staged changes should be accepted, including deletions.
	Soft
	// Hard indicates locally staged changes should be discarded.
	Hard
)
type Links struct {
	// URL is the thread URL, which maps to a ThreadDB collection instance.
	URL string `json:"url"`
	// WWW is the URL at which the bucket will be rendered as a website (requires remote DNS configuration).
	WWW string `json:"www"`
	// IPNS is the bucket IPNS address.
	IPNS string `json:"ipns"`
}

Links wraps remote link info for a bucket.

type MergeStrategy

type MergeStrategy string

MergeStrategy describes the type of path merge strategy.

type Metadata

type Metadata struct {
	Key       string                  `json:"key,omitempty"`
	Roles     map[string]buckets.Role `json:"roles,omitempty"`
	UpdatedAt time.Time               `json:"updated_at"`
}

Metadata wraps metadata about a bucket item.

type NewOption

type NewOption func(*newOptions)

NewOption is used when creating a new bucket.

func WithCid

func WithCid(c cid.Cid) NewOption

WithCid indicates an inited bucket should be boostraped with a particular UnixFS DAG.

func WithInitEvents added in v2.6.0

func WithInitEvents(ch chan<- Event) NewOption

WithInitEvents allows the caller to receive events when pulling files from an existing bucket on initialization.

func WithName

func WithName(name string) NewOption

WithName sets a name for the bucket.

func WithPrivate

func WithPrivate(private bool) NewOption

WithPrivate specifies that an encryption key will be used for the bucket.

func WithStrategy added in v2.5.0

func WithStrategy(strategy InitStrategy) NewOption

WithStrategy allows for selecting the init strategy. Hybrid is the default.

func WithUnfreeze added in v2.6.0

func WithUnfreeze(enabled bool) NewOption

WithUnfreeze indicates that the bucket should be bootstrapped from Filecoin.

type Path added in v2.5.0

type Path struct {
	path.Resolved
}

Path wraps path.Resolved so it can be JSON-marshalable.

func (Path) MarshalJSON added in v2.5.0

func (p Path) MarshalJSON() ([]byte, error)

type PathInvite

type PathInvite struct {
	Thread string `json:"thread"`
	Key    string `json:"key"`
	Path   string `json:"path"`
}

PathInvite wraps information needed to collaborate on a bucket path.

type PathOption

type PathOption func(*pathOptions)

PathOption is used when pushing or pulling bucket paths.

func WithConfirm

func WithConfirm(f ConfirmDiffFunc) PathOption

WithConfirm allows the caller to confirm a list of bucket changes.

func WithEvents added in v2.6.0

func WithEvents(ch chan<- Event) PathOption

WithEvents allows the caller to receive events when pushing or pulling files.

func WithForce

func WithForce(b bool) PathOption

WithForce indicates all remote files should be pulled even if they already exist.

func WithHard

func WithHard(b bool) PathOption

WithHard indicates locally staged changes should be discarded.

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo tracks a local bucket tree structure.

func NewRepo

func NewRepo(pth, name string, layout options.Layout) (*Repo, error)

NewRepo creates a new bucket with the given path.

func (*Repo) CidVersion

func (b *Repo) CidVersion() int

CidVersion gets the repo cid version (0 or 1).

func (*Repo) Close

func (b *Repo) Close() error

Close closes the store and blocks service.

func (*Repo) Diff

func (b *Repo) Diff(ctx context.Context, pth string) (diff []*du.Change, err error)

Diff returns a list of changes that are present in path compared to the bucket.

func (*Repo) GetNode

func (b *Repo) GetNode(ctx context.Context, c cid.Cid) (ipld.Node, error)

GetNode returns the node at cid from the bucket.

func (*Repo) GetPathMap

func (b *Repo) GetPathMap(pth string) (local, remote cid.Cid, err error)

GetPathMap returns details about a local path.

func (*Repo) HashFile

func (b *Repo) HashFile(pth string) (cid.Cid, error)

HashFile returns the cid of the file at path. This method does not alter the bucket.

func (*Repo) MatchPath

func (b *Repo) MatchPath(pth string, local, remote cid.Cid) (bool, error)

MatchPath returns whether or not the path exists and has matching local and remote cids.

func (*Repo) Path

func (b *Repo) Path() string

Path returns the repo path.

func (*Repo) RemovePath

func (b *Repo) RemovePath(ctx context.Context, pth string) error

RemovePath removes a local path map from the store.

func (*Repo) Root

func (b *Repo) Root() (local, remote cid.Cid, err error)

Root returns the local and remote root cids.

func (*Repo) Save

func (b *Repo) Save(ctx context.Context) error

Save saves the bucket as a node describing the file tree at the current path.

func (*Repo) SaveFile

func (b *Repo) SaveFile(ctx context.Context, pth string, name string) error

SaveFile saves the file at path to the repo.

func (*Repo) SetCidVersion

func (b *Repo) SetCidVersion(v int)

SetCidVersion set the repo cid version (0 or 1). The default version is 1.

func (*Repo) SetRemotePath

func (b *Repo) SetRemotePath(pth string, remote cid.Cid) error

SetRemotePath sets or creates a mapping from a local path to a remote cid.

type Roots

type Roots struct {
	Local  cid.Cid `json:"local"`
	Remote cid.Cid `json:"remote"`
}

Roots wraps local and remote root cids. If the bucket is not private (encrypted), these will be the same.

type SelectMergeFunc

type SelectMergeFunc func(description string, isDir bool) (MergeStrategy, error)

SelectMergeFunc is a caller-provided function which is used to select a merge strategy.

type WatchOption

type WatchOption func(*watchOptions)

WatchOption is used when watching a bucket for changes.

func WithOffline

func WithOffline(offline bool) WatchOption

WithOffline will keep watching for bucket changes while the local network is offline.

func WithWatchEvents

func WithWatchEvents(ch chan<- Event) WatchOption

WithWatchEvents allows the caller to receive events when watching a bucket for changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL