Documentation ¶
Overview ¶
Package tree implements a tree whose nodes are DirEntry entries.
Index ¶
- type Tree
- func (t *Tree) Close() error
- func (t *Tree) Delete(p path.Parsed) (*upspin.DirEntry, error)
- func (t *Tree) Flush() error
- func (t *Tree) List(prefix path.Parsed) ([]*upspin.DirEntry, bool, error)
- func (t *Tree) Lookup(p path.Parsed) (de *upspin.DirEntry, dirty bool, err error)
- func (t *Tree) OnEviction(key interface{})
- func (t *Tree) Put(p path.Parsed, de *upspin.DirEntry) (*upspin.DirEntry, error)
- func (t *Tree) PutDir(dstDir path.Parsed, de *upspin.DirEntry) (*upspin.DirEntry, error)
- func (t *Tree) String() string
- func (t *Tree) User() *serverlog.User
- func (t *Tree) Watch(p path.Parsed, sequence int64, done <-chan struct{}) (<-chan *upspin.Event, error)
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 ¶
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 ¶
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 ¶
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) List ¶
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 ¶
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 ¶
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.