Documentation ¶
Index ¶
- Variables
- type Change
- type Commit
- type Diff
- type DiffPair
- type ErrNoSuchHash
- type ExplicitPin
- type FS
- func (fs *FS) ApplyPatch(data []byte) error
- func (fs *FS) Cat(path string) (mio.Stream, error)
- func (fs *FS) Checkout(rev string, force bool) error
- func (fs *FS) ClearExplicitPins(prefix, fromRef, toRef string) (int, error)
- func (fs *FS) Close() error
- func (fs *FS) Copy(src, dst string) error
- func (fs *FS) Export(w io.Writer) error
- func (fs *FS) FilesByContent(contents []h.Hash) (map[string]StatInfo, error)
- func (fs *FS) Head() (string, error)
- func (fs *FS) History(path string) ([]Change, error)
- func (fs *FS) Import(r io.Reader) error
- func (fs *FS) IsPinned(path string) (bool, bool, error)
- func (fs *FS) LastPatchIndex() (int64, error)
- func (fs *FS) List(root string, maxDepth int) ([]*StatInfo, error)
- func (fs *FS) ListExplicitPins(prefix, fromRef, toRef string) ([]ExplicitPin, error)
- func (fs *FS) Log() ([]Commit, error)
- func (fs *FS) MakeCommit(msg string) error
- func (fs *FS) MakeDiff(remote *FS, headRevOwn, headRevRemote string) (*Diff, error)
- func (fs *FS) MakePatch(fromRev string, folders []string, remoteName string) ([]byte, error)
- func (fs *FS) Mkdir(path string, createParents bool) error
- func (fs *FS) Move(src, dst string) error
- func (fs *FS) Open(path string) (*Handle, error)
- func (fs *FS) Pin(path string) error
- func (fs *FS) Remove(path string) error
- func (fs *FS) RemoveTag(name string) error
- func (fs *FS) Reset(path, rev string) error
- func (fs *FS) ScheduleGCRun()
- func (fs *FS) SetExplicitPin(prefix, fromRef, toRef string) (int, error)
- func (fs *FS) Stage(path string, r io.ReadSeeker) error
- func (fs *FS) Stat(path string) (*StatInfo, error)
- func (fs *FS) Sync(remote *FS) error
- func (fs *FS) Tag(rev, name string) error
- func (fs *FS) Touch(path string) error
- func (fs *FS) Truncate(path string, size uint64) error
- func (fs *FS) Unpin(path string) error
- type FsBackend
- type Handle
- func (hdl *Handle) Close() error
- func (hdl *Handle) Flush() error
- func (hdl *Handle) Path() string
- func (hdl *Handle) Read(buf []byte) (int, error)
- func (hdl *Handle) Seek(offset int64, whence int) (int64, error)
- func (hdl *Handle) Truncate(size uint64) error
- func (hdl *Handle) Write(buf []byte) (int, error)
- type MemFsBackend
- type Pinner
- func (pc *Pinner) Close() error
- func (pc *Pinner) IsNodePinned(nd n.Node) (bool, bool, error)
- func (pc *Pinner) IsPinned(hash h.Hash) (isPinned bool, isExplicit bool, err error)
- func (pc *Pinner) Pin(hash h.Hash, explicit bool) error
- func (pc *Pinner) PinNode(nd n.Node, explicit bool) error
- func (pc *Pinner) Unpin(hash h.Hash, explicit bool) error
- func (pc *Pinner) UnpinNode(nd n.Node, explicit bool) error
- type StatInfo
Constants ¶
This section is empty.
Variables ¶
var (
ErrIsClosed = errors.New("File handle is closed")
)
var ErrReadOnly = errors.New("fs is read only")
Functions ¶
This section is empty.
Types ¶
type Commit ¶
Commit gives information about a single commit. TODO: Decide on naming: rev(ision), refname or tag.
type ErrNoSuchHash ¶
type ErrNoSuchHash struct {
// contains filtered or unexported fields
}
ErrNoSuchHash should be returned whenever the backend is unable to find an object referenced to by this hash.
func (ErrNoSuchHash) Error ¶
func (eh ErrNoSuchHash) Error() string
type ExplicitPin ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS (short for Filesystem) is the central API entry for everything related to paths. It exposes a POSIX-like interface where path are mapped to the actual underlying hashes and the associated metadata.
Additionally it supports version control commands like MakeCommit(), Checkout() etc. The API is file-centric, i.e. directories are created on the fly for some operations like Stage(). Empty directories can be created via Mkdir() though.
func NewFilesystem ¶
func (*FS) ApplyPatch ¶
ApplyPatch reads the binary patch coming from MakePatch and tries to apply it.
func (*FS) Cat ¶
Cat will open a file read-only and expose it's underlying data as stream. If no such path is known or it was deleted, nil is returned as stream.
func (*FS) ClearExplicitPins ¶
func (*FS) FilesByContent ¶
func (*FS) IsPinned ¶
IsPinned returns true for files and directories that are pinned. A directory only counts as pinned if all files and directories in it are also pinned.
func (*FS) LastPatchIndex ¶
LastPatchIndex will return the current version of this filesystem regarding patch state.
func (*FS) List ¶
List returns stat info for each node below (and including) root. Nodes deeper than maxDepth will not be shown. If maxDepth is a negative number, all nodes will be shown.
func (*FS) ListExplicitPins ¶
func (fs *FS) ListExplicitPins(prefix, fromRef, toRef string) ([]ExplicitPin, error)
func (*FS) Log ¶
Log returns a list of commits starting with the staging commit until the initial commit. For each commit, metadata is collected.
func (*FS) MakeCommit ¶
MakeCommit bundles all staged changes into one commit described by `msg`. If no changes were made since the last call to MakeCommit() ErrNoConflict is returned.
func (*FS) MakePatch ¶
MakePatch creates a binary patch with all file changes starting with `fromRev`. Note that commit information is not exported, only individual file and directory changes.
The byte structured returned by this method may change at any point and may not be relied upon.
The `remoteName` is the name of the remote we're creating the patch for. It's only used for display purpose in the commit message.
func (*FS) Open ¶
Open returns a file like object that can be used for modifying a file in memory. If you want to have seekable read-only stream, use Cat(), it has less overhead.
func (*FS) ScheduleGCRun ¶
func (fs *FS) ScheduleGCRun()
func (*FS) SetExplicitPin ¶
func (*FS) Stage ¶
func (fs *FS) Stage(path string, r io.ReadSeeker) error
Stage reads all data from `r` and stores as content of the node at `path`. If `path` already exists, it will be updated.
func (*FS) Sync ¶
Sync will synchronize the state of two filesystems. If one of filesystems have unstaged changes, they will be committted first. If our filesystem was changed by Sync(), a new merge commit will also be created.
func (*FS) Tag ¶
Tag saves a human readable name for the revision pointed to by `rev`. There are three pre-defined tags available:
- HEAD: The last full commit. - CURR: The current commit (== staging commit) - INIT: the initial commit.
The tagname is case-insensitive.
func (*FS) Touch ¶
Touch creates an empty file at `path` if it does not exist yet. If it exists, it's mod time is being updated to the current time.
func (*FS) Truncate ¶
Truncate cuts of the output of the file at `path` to `size`. `size` should be between 0 and the size of the file, all other values will be ignored.
Note that this is not implemented as an actual IO operation. It is possible to go back to a bigger size until the actual content was changed via Stage().
type FsBackend ¶
type FsBackend interface { // Cat should find the object referenced to by `hash` and // make its data available as mio.Stream. Cat(hash h.Hash) (mio.Stream, error) // Add should read all data in `r` and return the hash under // which it can be accessed on later. Add(r io.Reader) (h.Hash, error) // Pin gives the object at `hash` a "pin". // (i.e. it marks the file to be stored indefinitely in local storage) // When pinning an explicit pin with an implicit pin, the explicit pin // will stay. Upgrading from implicit to explicit is possible though. Pin(hash h.Hash) error // Unpin removes a previously added pin. // If an object is already unpinned this is a no op. Unpin(hash h.Hash) error // IsPinned return two boolean values: // - If the first value is true, the file is pinned. IsPinned(hash h.Hash) (bool, error) }
FsBackend is the interface that needs to be implemented by the data management layer.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
type MemFsBackend ¶
type MemFsBackend struct {
// contains filtered or unexported fields
}
MemFsBackend is a mock structure that implements FsBackend.
func NewMemFsBackend ¶
func NewMemFsBackend() *MemFsBackend
NewMemFsBackend returns a MemFsBackend (useful for writing tests)
func (*MemFsBackend) IsPinned ¶
func (mb *MemFsBackend) IsPinned(hash h.Hash) (bool, error)
IsPinned implements FsBackend.IsPinned by querying a marker in memory.
type Pinner ¶
type Pinner struct {
// contains filtered or unexported fields
}
Pinner remembers which hashes are pinned and if they are pinned explicitly. It offers also safe API to change this state easily.
func NewPinner ¶
NewPinner creates a new pin cache at `pinDbPath`, possibly erroring out. `lkr` and `bk` are used to make PinNode() and UnpinNode() work.
func (*Pinner) IsNodePinned ¶
IsNodePinned checks if all `nd` is pinned and if so, exlusively. If `nd` is a directory, it will only return true if all children are also pinned (same for second return value).
func (*Pinner) PinNode ¶
PinNode tries to pin the node referenced by `nd`. The difference to calling Pin(nd.BackendHash()) is, that this method will pin directories recursively, if given.
If the file is already pinned exclusively and you want to pin it non-exclusive, this will be a no-op. In this case you have to unpin it first exclusively.
type StatInfo ¶
type StatInfo struct { Path string TreeHash h.Hash User string Size uint64 Inode uint64 IsDir bool Depth int ModTime time.Time IsPinned bool IsExplicit bool ContentHash h.Hash BackendHash h.Hash }
StatInfo describes the metadata of a single node. The concept is comparable to the POSIX stat() call.
Directories ¶
Path | Synopsis |
---|---|
package mio (short for memory input/output) implements the layered io stack of brig.
|
package mio (short for memory input/output) implements the layered io stack of brig. |
encrypt
Package encrypt implements the encryption layer of brig.
|
Package encrypt implements the encryption layer of brig. |
Package nodes implements all nodes and defines basic operations on it.
|
Package nodes implements all nodes and defines basic operations on it. |