Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPassword(baseFolder, password string) error
- func Init(baseFolder, owner, password, backendName string, daemonPort int64) error
- func LockRepo(root, user, password string, lockExcludes, unlockExcludes []string) error
- func UnlockRepo(root, user, password string, lockExcludes, unlockExcludes []string) error
- type Backend
- type Folder
- type Keyring
- type Remote
- type RemoteList
- func (rl *RemoteList) AddOrUpdateRemote(remote Remote) error
- func (rl *RemoteList) Clear() error
- func (rl *RemoteList) Export(w io.Writer) error
- func (rl *RemoteList) ListRemotes() ([]Remote, error)
- func (rl *RemoteList) Remote(name string) (Remote, error)
- func (rl *RemoteList) RmRemote(name string) error
- func (rl *RemoteList) SaveList(remotes []Remote) error
- type Repository
- func (rp *Repository) BackendName() string
- func (rp *Repository) BackendPath(name string) string
- func (rp *Repository) Close(password string) error
- func (rp *Repository) CurrentUser() string
- func (rp *Repository) FS(owner string, bk catfs.FsBackend) (*catfs.FS, error)
- func (rp *Repository) GC(backend Backend, aggressive bool) (map[string]map[string]h.Hash, error)
- func (rp *Repository) HaveFS(owner string) bool
- func (rp *Repository) Keyring() *Keyring
- func (rp *Repository) RepoID() (string, error)
- func (rp *Repository) SaveConfig() error
- func (rp *Repository) SetCurrentUser(user string)
Constants ¶
const ( // LockPathSuffix is the suffix appended to each file in its locked state. LockPathSuffix = ".locked" // LockDirSuffix is the suffix appended to each directory in its locked state. LockDirSuffix = ".tgz" + LockPathSuffix )
Variables ¶
var ( // ErrBadPassword is returned by Open() when the decyption password seems to be wrong. ErrBadPassword = errors.New("Failed to open repository. Probably wrong password") )
var ( // ErrNoSuchRemote will be returned by various remote functions // when a non-existing remote was requested. ErrNoSuchRemote = errors.New("No such remote with this name") )
Functions ¶
func CheckPassword ¶
CheckPassword will try to validate `password` by decrypting something in `baseFolder`.
func Init ¶
Init will create a new repository on disk at `baseFolder`. `owner` will be the new owner and should be something like user@domain/resource. `backendName` is the name of the backend, either "ipfs" or "mock". `daemonPort` is the port of the local daemon.
func LockRepo ¶
LockRepo encrypts all files (except those in `lockExcludes`) in `root`, depending on `user` and `password`. `unlockExcludes` is only used to prevent warnings about not locked files.
func UnlockRepo ¶
UnlockRepo is the exact opposite of LockRepo.
Types ¶
type Backend ¶
Backend defines the method needed from the underlying storage backend to create & manage a repository.
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring manages our own keypair and stores the last known pubkeys of other remotes.
func (*Keyring) Decrypt ¶
Decrypt decrypts a message encrypted with our public key. This is not an efficient method and is not supposed to be used for large amounts of data.
func (*Keyring) Encrypt ¶
Encrypt `data` with `pubKey`. If it's desired to encrypt a message with our own pubkey, then use the PubKeyBytes() method to load one. This is not an efficient method and is not supposed to be used for large amounts of data.
type Remote ¶
type Remote struct { // Name is the name of the remote. // This name can be freely chosen. Name string // Folders is a list of folders the remote has access to. // If this list is empty, this remote may access all folders. Folders []Folder // Fingerprint is the fingerprint of the remote. Fingerprint peer.Fingerprint }
Remote is one entry in the remote list. It defines what users we may talk to (and also how)
type RemoteList ¶
type RemoteList struct {
// contains filtered or unexported fields
}
RemoteList is a helper that parses the remote access yml file and makes it easily accessible from the Go side.
func NewRemotes ¶
func NewRemotes(path string) (*RemoteList, error)
NewRemotes returns a new RemoteList.
func (*RemoteList) AddOrUpdateRemote ¶ added in v0.2.0
func (rl *RemoteList) AddOrUpdateRemote(remote Remote) error
AddOrUpdateRemote will add/update a remote.
func (*RemoteList) Clear ¶
func (rl *RemoteList) Clear() error
Clear will remove all of the remote list.
func (*RemoteList) Export ¶
func (rl *RemoteList) Export(w io.Writer) error
Export writes the contents of the remote list to `w` in YAML format.
func (*RemoteList) ListRemotes ¶
func (rl *RemoteList) ListRemotes() ([]Remote, error)
ListRemotes will return a copy of the remote list entries.
func (*RemoteList) Remote ¶
func (rl *RemoteList) Remote(name string) (Remote, error)
Remote will return the remote named `name`. If there is not such remote, ErrNoSuchRemote is returned.
func (*RemoteList) RmRemote ¶
func (rl *RemoteList) RmRemote(name string) error
RmRemote will remove a remote by `name`. If there is not such remote, ErrNoSuchRemote is returned.
func (*RemoteList) SaveList ¶
func (rl *RemoteList) SaveList(remotes []Remote) error
SaveList will store the contents of `remotes` to disk.
type Repository ¶
type Repository struct { // Absolute path to the repository root BaseFolder string // Name of the owner of this repository Owner string // Config interface Config *config.Config // Remotes gives access to all known remotes Remotes *RemoteList // contains filtered or unexported fields }
Repository provides access to the file structure of a single repository.
Informal: This file structure currently looks like this: config.yml OWNER BACKEND REPO_ID remotes.yml data/
<backend_name> (data-backend specific)
metadata/
<name_1> (fs-backend specific) <name_2> (fs-backend specific)
func Open ¶
func Open(baseFolder, password string) (*Repository, error)
Open will open the repository at `baseFolder` by using `password`.
func (*Repository) BackendName ¶
func (rp *Repository) BackendName() string
BackendName returns the backend name used when constructing the repo.
func (*Repository) BackendPath ¶
func (rp *Repository) BackendPath(name string) string
BackendPath returns the absolute path to the backend folder inside the repo.
func (*Repository) Close ¶
func (rp *Repository) Close(password string) error
Close will lock the repository, making this instance unusable.
func (*Repository) CurrentUser ¶
func (rp *Repository) CurrentUser() string
CurrentUser returns the current user of the repository. (i.e. what FS is being shown)
func (*Repository) FS ¶
FS returns a filesystem for `owner`. If there is none yet, it will create own associated to the respective owner.
func (*Repository) GC ¶
GC runs the garbage collector of the backend. If `aggressive` is true, also the internal data structures will be garbage collected, which might lead to minimally less storage. It returns a map of maps, where the inner map consists of content hash58 to binary representation of the same hash. The outer key is the owner of the file.
func (*Repository) HaveFS ¶
func (rp *Repository) HaveFS(owner string) bool
HaveFS will return true if we have data for a certain owner.
func (*Repository) Keyring ¶
func (rp *Repository) Keyring() *Keyring
Keyring returns the keyring of the repository.
func (*Repository) RepoID ¶ added in v0.2.0
func (rp *Repository) RepoID() (string, error)
RepoID returns a unique ID specific to this repository.
func (*Repository) SaveConfig ¶ added in v0.2.0
func (rp *Repository) SaveConfig() error
SaveConfig dumps the in memory config to disk.
func (*Repository) SetCurrentUser ¶
func (rp *Repository) SetCurrentUser(user string)
SetCurrentUser sets the current user of the repository. (i.e. called by "become" when changing the FS)