Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPassword(baseFolder, password string) error
- func Init(baseFolder, owner, password, backendName string) 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 Perms
- type Remote
- type RemoteList
- func (rl *RemoteList) AddRemote(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 RemotePerms
- 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) SetCurrentUser(user string)
Constants ¶
const ( LockPathSuffix = ".locked" LockDirSuffix = ".tgz" + LockPathSuffix )
const ( PermNone = 0 PermRead = 1 << iota PermWrite )
Variables ¶
var Defaults = []struct { Name string Value interface{} }{ {"daemon.port", 6666}, {"sync.ignore_removed", false}, {"sync.conflict_strategy", "marker"}, {"data.ipfs.path", ""}, {"data.compress.algo", "snappy"}, }
var (
ErrBadPassword = errors.New("Failed to open repository. Probably wrong password")
)
var (
ErrNoSuchRemote = errors.New("No such remote with this name")
)
Functions ¶
func CheckPassword ¶
func UnlockRepo ¶
Types ¶
type Backend ¶
type Backend interface { // ForwardLog writes all logs of the backend to `w`. // The log level is chosen by the backend itself. ForwardLog(w io.Writer) GC() ([]h.Hash, error) }
Backend defines the method needed from the underlying storage backend to create & manage a repository.
type Folder ¶
type Folder struct { Folder string Perms RemotePerms }
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 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)
func (*RemoteList) AddRemote ¶
func (rl *RemoteList) AddRemote(remote Remote) error
func (*RemoteList) Clear ¶
func (rl *RemoteList) Clear() error
func (*RemoteList) ListRemotes ¶
func (rl *RemoteList) ListRemotes() ([]Remote, error)
func (*RemoteList) RmRemote ¶
func (rl *RemoteList) RmRemote(name string) error
func (*RemoteList) SaveList ¶
func (rl *RemoteList) SaveList(remotes []Remote) error
type RemotePerms ¶
type RemotePerms int
func (RemotePerms) FromStrings ¶
func (rp RemotePerms) FromStrings(perms []string) RemotePerms
func (RemotePerms) String ¶
func (rp RemotePerms) String() string
func (RemotePerms) ToStrings ¶
func (rp RemotePerms) ToStrings() []string
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 *viper.Viper // 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 meta.yml 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)
func (*Repository) BackendName ¶
func (rp *Repository) BackendName() string
func (*Repository) BackendPath ¶
func (rp *Repository) BackendPath(name string) string
func (*Repository) Close ¶
func (rp *Repository) Close(password string) error
func (*Repository) CurrentUser ¶
func (rp *Repository) CurrentUser() string
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) 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
func (*Repository) SetCurrentUser ¶
func (rp *Repository) SetCurrentUser(user string)