Documentation ¶
Overview ¶
Package rufs contains the main API to Rufs.
Rufs is organized as a collection of branches. Each branch represents a physical file system structure which can be queried and updated by an authorized client.
On the client side one or several branches are organized into a tree. The single branches can overlay each other. For example:
Branch A /foo/A /foo/B /bar/C
Branch B /foo/C /test/D
Tree 1 /myspace => Branch A, Branch B
Accessing tree with: /myspace/foo/A gets file /foo/A from Branch A while /myspace/foo/C gets file /foo/C from Branch B
Write operations go only to branches which are mapped as writing branches and who accept them (i.e. are not set to readonly on the side of the branch).
Index ¶
- Constants
- Variables
- func DirResultToString(paths []string, infos [][]os.FileInfo) string
- func IsEOF(err error) bool
- func WrapFileInfo(path string, i os.FileInfo) os.FileInfo
- func WrapFileInfos(path string, is []os.FileInfo) []os.FileInfo
- type Branch
- func (b *Branch) Dir(spath string, pattern string, recursive bool, checksums bool) ([]string, [][]os.FileInfo, error)
- func (b *Branch) IsReadOnly() bool
- func (b *Branch) ItemOp(spath string, opdata map[string]string) (bool, error)
- func (b *Branch) Name() string
- func (b *Branch) ReadFile(spath string, p []byte, offset int64) (int, error)
- func (b *Branch) ReadFileToBuffer(spath string, buf io.Writer) error
- func (b *Branch) SSLFingerprint() string
- func (b *Branch) Shutdown() error
- func (b *Branch) WriteFile(spath string, p []byte, offset int64) (int, error)
- func (b *Branch) WriteFileFromBuffer(spath string, buf io.Reader) error
- type FileInfo
- type Tree
- func (t *Tree) ActiveBranches() ([]string, []string)
- func (t *Tree) AddBranch(branchName string, branchRPC string, branchFingerprint string) error
- func (t *Tree) AddMapping(dir, branchName string, writable bool) error
- func (t *Tree) Config() string
- func (t *Tree) Copy(src []string, dst string, ...) error
- func (t *Tree) CopyFile(srcPath, dstPath string, updFunc func(writtenBytes int)) error
- func (t *Tree) Dir(dir string, pattern string, recursive bool, checksums bool) ([]string, [][]os.FileInfo, error)
- func (t *Tree) ItemOp(dir string, opdata map[string]string) (bool, error)
- func (t *Tree) KnownBranches() map[string]map[string]string
- func (t *Tree) NotReachableBranches() map[string]map[string]string
- func (t *Tree) PingBranch(node string, rpc string) (string, error)
- func (t *Tree) ReadFile(spath string, p []byte, offset int64) (int, error)
- func (t *Tree) ReadFileToBuffer(spath string, buf io.Writer) error
- func (t *Tree) Refresh()
- func (t *Tree) Reset(branches bool)
- func (t *Tree) SetMapping(config string) error
- func (t *Tree) Stat(item string) (os.FileInfo, error)
- func (t *Tree) String() string
- func (t *Tree) Sync(srcDir string, dstDir string, recursive bool, ...) error
- func (t *Tree) WriteFile(spath string, p []byte, offset int64) (int, error)
- func (t *Tree) WriteFileFromBuffer(spath string, buf io.Reader) error
Constants ¶
const ( ItemOpAction = "itemop_action" // ItemOp action ItemOpName = "itemop_name" // Item name ItemOpNewName = "itemop_newname" // New item name )
ItemOp parameter
const ( ItemOpActRename = "rename" // Rename a file or directory ItemOpActDelete = "delete" // Delete a file or directory ItemOpActMkDir = "mkdir" // Create a directory )
ItemOp actions
const ( ParamAction = "a" // Requested action ParamPath = "p" // Path string ParamPattern = "x" // Pattern string ParamRecursive = "r" // Recursive flag ParamChecksums = "c" // Checksum flag ParamOffset = "o" // Offset parameter ParamSize = "s" // Size parameter )
Meta parameter
const ( OpDir = "dir" // Read the contents of a path OpRead = "read" // Read the contents of a file OpWrite = "write" // Read the contents of a file OpItemOp = "itemop" // File or directory operation )
Possible actions
const ( SyncCreateDirectory = "Create directory" SyncCopyFile = "Copy file" SyncRemoveDirectory = "Remove directory" SyncRemoveFile = "Remove file" )
Sync operations
Variables ¶
var DefaultReadBufferSize = 1024 * 16
DefaultReadBufferSize is the default size for file reading.
Functions ¶
func DirResultToString ¶
DirResultToString formats a given Dir result into a human-readable string.
func WrapFileInfo ¶
WrapFileInfo wraps a single os.FileInfo object in a serializable FileInfo.
Types ¶
type Branch ¶
type Branch struct {
// contains filtered or unexported fields
}
Branch models a single exported branch in Rufs.
func NewBranch ¶
func NewBranch(cfg map[string]interface{}, cert *tls.Certificate) (*Branch, error)
NewBranch returns a new exported branch.
func (*Branch) Dir ¶
func (b *Branch) Dir(spath string, pattern string, recursive bool, checksums bool) ([]string, [][]os.FileInfo, error)
Dir returns file listings matching a given pattern of one or more directories. The contents of the given path is returned along with checksums if the checksum flag is specified. Optionally, also the contents of all subdirectories can be returned if the recursive flag is set. The return values is a list of traversed directories (platform-agnostic) and their corresponding contents.
func (*Branch) IsReadOnly ¶
IsReadOnly returns if this branch is read-only.
func (*Branch) ItemOp ¶
ItemOp executes a file or directory specific operation which can either succeed or fail (e.g. rename or delete). Actions and parameters should be given in the opdata map.
func (*Branch) ReadFile ¶
ReadFile reads up to len(p) bytes into p from the given offset. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
func (*Branch) ReadFileToBuffer ¶
ReadFileToBuffer reads a complete file into a given buffer which implements io.Writer.
func (*Branch) SSLFingerprint ¶
SSLFingerprint returns the SSL fingerprint of the branch.
type FileInfo ¶
type FileInfo struct { FiName string // Base name FiSize int64 // Size in bytes FiMode os.FileMode // File mode bits FiModTime time.Time // Modification time FiChecksum string // Checksum of files // contains filtered or unexported fields }
FileInfo implements os.FileInfo in an platform-agnostic way
func (*FileInfo) Checksum ¶
Checksum returns the checksum of this file. May be an empty string if it was not calculated.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree models a Rufs client which combines several branches.
func NewTree ¶
func NewTree(cfg map[string]interface{}, cert *tls.Certificate) (*Tree, error)
NewTree creates a new tree.
func (*Tree) ActiveBranches ¶
ActiveBranches returns a list of all known active branches and their fingerprints.
func (*Tree) AddMapping ¶
AddMapping adds a mapping from tree path to a branch.
func (*Tree) Copy ¶
func (t *Tree) Copy(src []string, dst string, updFunc func(file string, writtenBytes, totalBytes, currentFile, totalFiles int64)) error
Copy is a general purpose copy function which creates files and directories. Destination must be a directory. A non-existing destination directory will be created.
func (*Tree) Dir ¶
func (t *Tree) Dir(dir string, pattern string, recursive bool, checksums bool) ([]string, [][]os.FileInfo, error)
Dir returns file listings matching a given pattern of one or more directories. The contents of the given path is returned. Optionally, also the contents of all subdirectories can be returned if the recursive flag is set. The return values is a list of traversed directories and their corresponding contents.
func (*Tree) ItemOp ¶
ItemOp executes a file or directory specific operation which can either succeed or fail (e.g. rename or delete). Actions and parameters should be given in the opdata map.
func (*Tree) KnownBranches ¶
KnownBranches returns a map of all known branches (active or not reachable). Caution: This map contains also the map of active branches with their fingerprints it should only be used for read operations.
func (*Tree) NotReachableBranches ¶
NotReachableBranches returns a map of all known branches which couldn't be reached. The map contains the name and the definition of the branch.
func (*Tree) PingBranch ¶
PingBranch sends a ping to a remote branch and returns its fingerprint or an error.
func (*Tree) ReadFile ¶
ReadFile reads up to len(p) bytes into p from the given offset. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
func (*Tree) ReadFileToBuffer ¶
ReadFileToBuffer reads a complete file into a given buffer which implements io.Writer.
func (*Tree) Refresh ¶
func (t *Tree) Refresh()
Refresh refreshes all known branches and mappings. Only reachable branches will be mapped into the tree.
func (*Tree) Reset ¶
Reset either resets only all mounts or if the branches flag is specified also all known branches.
func (*Tree) SetMapping ¶
SetMapping adds a given tree mapping configuration in a JSON string.
func (*Tree) Stat ¶
Stat returns information about a given item. Use this function to find out if a given path is a file or directory.
func (*Tree) Sync ¶
func (t *Tree) Sync(srcDir string, dstDir string, recursive bool, updFunc func(op, srcFile, dstFile string, writtenBytes, totalBytes, currentFile, totalFiles int64)) error
Sync a given destination with a given source directory. After this command has finished the dstDir will have the same files and directories as the srcDir.
Directories ¶
Path | Synopsis |
---|---|
Package api contains the REST API for RUFS.
|
Package api contains the REST API for RUFS. |
v1
Package v1 contains Rufs REST API Version 1.
|
Package v1 contains Rufs REST API Version 1. |
Rufs main entry point for the standalone server.
|
Rufs main entry point for the standalone server. |
Package export contains export bindings for Rufs.
|
Package export contains export bindings for Rufs. |
integration
|
|
rumble
Package rumble contains Rumble functions which interface with Rufs.
|
Package rumble contains Rumble functions which interface with Rufs. |
Package node contains the network communication code for Rufs via RPC calls.
|
Package node contains the network communication code for Rufs via RPC calls. |
Package term contains a terminal implementation which can control Rufs trees.
|
Package term contains a terminal implementation which can control Rufs trees. |