tree

package
v0.0.0-...-7c4ed6d Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package tree implements a tree whose nodes are DirEntry entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

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

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

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

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

func (t *Tree) Flush() error

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

func (*Tree) List

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

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

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

OnEviction implements cache.EvictionNotifier.

func (*Tree) Put

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

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

func (t *Tree) String() string

String implements fmt.Stringer.

func (*Tree) User

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

func (*Tree) Watch

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

Watch implements upspin.DirServer.Watch.

Jump to

Keyboard shortcuts

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