core

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrEntryAlreadyExists

type ErrEntryAlreadyExists struct {
	Path string
}

ErrEntryAlreadyExists is returned when the entry requested already exists.

func (ErrEntryAlreadyExists) Error

func (e ErrEntryAlreadyExists) Error() string

Error returns the error message.

type ErrEntryDoesntExist

type ErrEntryDoesntExist struct {
	Path string
}

ErrEntryDoesntExist is returned when the entry requested doesn't exist.

func (ErrEntryDoesntExist) Error

func (e ErrEntryDoesntExist) Error() string

Error returns the error message.

type ErrStoreDecrypted

type ErrStoreDecrypted struct {
	Path string
}

ErrStoreDecrypted is returned when a store is asked to be decrypted but it's already decrypted.

func (ErrStoreDecrypted) Error

func (e ErrStoreDecrypted) Error() string

Error returns the error message.

type ErrStoreEncrypted

type ErrStoreEncrypted struct {
	Path string
}

ErrStoreEncrypted is returned when an action is attempted that requires a decrypted store but the store is decrypted.

func (ErrStoreEncrypted) Error

func (e ErrStoreEncrypted) Error() string

Error returns the error message.

type Store

type Store struct {
	Path string
	// contains filtered or unexported fields
}

Store represents an Albatross store.

func Load

func Load(path string) (*Store, error)

Load returns a new Albatross store representation.

func (*Store) Attach

func (s *Store) Attach(path, attachmentPath string) error

Attach attaches a file to an entry by copying it into the entry's folder from the location specified. If the store is encrypted, it will return ErrStoreEncrypted.

func (*Store) Collection

func (s *Store) Collection() (*entries.Collection, error)

Collection returns the *entries.Collection for the store. It will give an error if the store is currently encrypted.

func (*Store) Create

func (s *Store) Create(path, content string) error

Create creates a new entry in the store. If the store is encrypted, it returns ErrStoreEncrypted. It takes a path relative to the entries folder, such as "food/pizza" and it will create intermediate directories.

func (*Store) Decrypt

func (s *Store) Decrypt(passwordFunc func() (string, error)) error

Decrypt decrypts the store. If the store is already decrypted, it will return ErrStoreDecrypted. It takes a password func, which is anything that returns a string and an error. This allows to specify the password without having to hard code it in.

func (*Store) Delete

func (s *Store) Delete(path string) error

Delete deletes an entry and all its attachments from the store. If the store is encrypted, it returns ErrStoreEncrypted. It takes a path relative to the entries folder, such as "food/pizza". The path given has to be an entry itself, this function cannot be used to delete whole folders of entries. If the entry given has subdirectories of entries itself, those subdirectories will be left intact. BUG(ollybritton): This code won't delete attachments if they're in a folder next to the entry. The code needs to recursively search all subdirectories to determine if they're folders or not.

func (*Store) DisableGit

func (s *Store) DisableGit()

DisableGit disables the use of git. Calling .UsingGit will still return true. The reasoning is that the store is still using Git, it's just Git functionality isn't being used by the client.

func (*Store) Encrypt

func (s *Store) Encrypt() error

Encrypt encrypts the store. If the store is already encrypted, it returns ErrStoreEncrypted.

func (*Store) Encrypted

func (s *Store) Encrypted() (bool, error)

Encrypted returns true or false depending on whether the store is encrypted or decrypted.

func (*Store) Update

func (s *Store) Update(path, content string) error

Update updates the given entry. If the store is encrypted, it returns ErrStoreEncrypted.

func (*Store) UsingGit

func (s *Store) UsingGit() bool

UsingGit returns true or false depending on whether the store is using Git. This will still return true after a call to .DisableGit. The reasoning is that the store is still using Git, it's just Git functionality isn't being used by the client.

Notes

Bugs

  • This code won't delete attachments if they're in a folder next to the entry. The code needs to recursively search all subdirectories to determine if they're folders or not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL