upspin.io: upspin.io/dir/server/tree Index | Files

package tree

import "upspin.io/dir/server/tree"

Package tree implements a tree whose nodes are DirEntry entries.

Index

Package Files

blocks.go tree.go watch.go

type Tree Uses

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

Tree is a representation of a directory tree for a single Upspin user. The tree reads and writes from/to its backing Store server, which is configured when instantiating the Tree. It uses a Log to log changes not yet committed to the Store.

func New Uses

func New(config upspin.Config, user *serverlog.User) (*Tree, error)

New creates an empty Tree using the server's config and the set of logs for a user. Config is used for contacting StoreServer, defining the default packing and setting the server name. All fields of the config must be defined. If there are unprocessed log entries in the Log, the Tree's state is recovered from it. TODO: Maybe New is doing too much work. Figure out how to break in two without returning an inconsistent new tree if log is unprocessed.

func (*Tree) Close Uses

func (t *Tree) Close() error

Close flushes all dirty blocks to Store and releases all resources used by the tree. Further uses of the tree will have unpredictable results.

func (*Tree) Delete Uses

func (t *Tree) Delete(p path.Parsed) (*upspin.DirEntry, error)

Delete deletes the entry associated with the path. If the path identifies a link, Delete will delete the link itself, not its target.

If the returned error is upspin.ErrFollowLink, the caller should retry the operation as outlined in the description for upspin.ErrFollowLink. (And in that case, the DirEntry will never represent the full path name of the argument.) Otherwise, the returned DirEntry will be nil whether the operation succeeded or not.

func (*Tree) Flush Uses

func (t *Tree) Flush() error

Flush flushes all dirty dir entries to the Tree's Store.

func (*Tree) List Uses

func (t *Tree) List(prefix path.Parsed) ([]*upspin.DirEntry, bool, error)

List lists the contents of a prefix. If prefix names a directory, all entries of the directory are returned. If prefix names a file, that file's entry is returned. List does not interpret wildcards. Dirty reports whether any DirEntry returned is dirty (and thus may contain outdated references).

If the returned error is upspin.ErrFollowLink, the caller should retry the operation as outlined in the description for upspin.ErrFollowLink. (And in that case, only one DirEntry will be returned, that of the link itself.)

func (*Tree) Lookup Uses

func (t *Tree) Lookup(p path.Parsed) (de *upspin.DirEntry, dirty bool, err error)

Lookup returns an entry that represents the path. The returned DirEntry may or may not have valid references inside. If dirty is true, the references are not up-to-date. Calling Flush in a critical section prior to Lookup will ensure the entry is not dirty.

If the returned error is ErrFollowLink, the caller should retry the operation as outlined in the description for upspin.ErrFollowLink. Otherwise in the case of error the returned DirEntry will be nil.

func (*Tree) OnEviction Uses

func (t *Tree) OnEviction(key interface{})

OnEviction implements cache.EvictionNotifier.

func (*Tree) Put Uses

func (t *Tree) Put(p path.Parsed, de *upspin.DirEntry) (*upspin.DirEntry, error)

Put puts an entry at path p into the Tree. If the entry exists, it will be overwritten.

If the returned error is ErrFollowLink, the caller should retry the operation as outlined in the description for upspin.ErrFollowLink (with the added step of updating the Name field of the argument DirEntry). Otherwise, the returned DirEntry will be the one put.

func (*Tree) PutDir Uses

func (t *Tree) PutDir(dstDir path.Parsed, de *upspin.DirEntry) (*upspin.DirEntry, error)

PutDir puts a DirEntry representing an existing directory (with existing DirBlocks) into the tree at the point represented by dstDir. The last element of dstDir must not yet exist. dstDir must not cross a link nor be the root directory. It returns the newly put entry.

func (*Tree) String Uses

func (t *Tree) String() string

String implements fmt.Stringer.

func (*Tree) User Uses

func (t *Tree) User() *serverlog.User

func (*Tree) Watch Uses

func (t *Tree) Watch(p path.Parsed, sequence int64, done <-chan struct{}) (<-chan *upspin.Event, error)

Watch implements upspin.DirServer.Watch.

Package tree imports 15 packages (graph) and is imported by 1 packages. Updated 2019-05-18. Refresh now. Tools for package owners.