core

package
v0.0.0-...-59fc51a Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2015 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ProtFileExt = ".synced"

Variables

This section is empty.

Functions

func ChangeQueueManager

func ChangeQueueManager(newChanges chan *Change, completedChanges chan *Change, errors chan error, die chan bool)

ChangeQueueManager establishes change processing workers and farms work out to them as needed.

func GetFreeRemotePath

func GetFreeRemotePath(s *SyncInfo) (path string, err error)

GetFreeRemotePath returns a path relative to s.RemoteBase() that is currently available and can be used for a protected file.

Types

type CacheEntry

type CacheEntry struct {
	// contains filtered or unexported fields
}

CacheEntry is an copy of the information from the backing database in Sync

func GetCacheEntryViaLocal

func GetCacheEntryViaLocal(s *SyncInfo, local string) (entry *CacheEntry, err error)

GetCacheEntryViaLocal returns the file cache entry located via the relative local path given

func GetCacheEntryViaRemote

func GetCacheEntryViaRemote(s *SyncInfo, remote string) (entry *CacheEntry, err error)

GetCacheEntryViaRemote returns the file cache entry located via the relative local path given

func NewCacheEntry

func NewCacheEntry(sync *SyncInfo, remotePath string, localPath string, localHash gocrypt.Hash, remoteHash gocrypt.Hash) (entry *CacheEntry)

NewCacheEntry generates a file cache entry ready to be inserted into the database. The caller must call Save() on the entry to actually save. All paths should be relative to sync's bases.

func (*CacheEntry) AbsLocalPath

func (e *CacheEntry) AbsLocalPath() string

AbsLocalPath returns the absolute path to the referenced local, unprotected file.

func (*CacheEntry) AbsRemotePath

func (e *CacheEntry) AbsRemotePath() string

AbsRemotePath returns the absolute path to the referenced remote (protected) file.

func (*CacheEntry) Delete

func (e *CacheEntry) Delete() error

Delete removes the cache entry from the database.

func (*CacheEntry) LocalHash

func (e *CacheEntry) LocalHash() gocrypt.Hash

LocalHash returns the last known hash of the local file

func (*CacheEntry) LocalPath

func (e *CacheEntry) LocalPath() string

LocalPath returns the path to the local file relative to sync.LocalBase()

func (*CacheEntry) MarkLocalSeen

func (e *CacheEntry) MarkLocalSeen() error

MarkLocalSeen marks the entry as seen by the initial scan

func (*CacheEntry) MarkRemoteSeen

func (e *CacheEntry) MarkRemoteSeen() error

MarkRemoteSeen marks the entry as seen by the initial scan

func (*CacheEntry) RemoteHash

func (e *CacheEntry) RemoteHash() gocrypt.Hash

RemoteHash returns the last known hash of the remote file

func (*CacheEntry) RemotePath

func (e *CacheEntry) RemotePath() string

RemotePath returns the path to the remote file relative to sync.RemoteBase()

func (*CacheEntry) Save

func (e *CacheEntry) Save() error

Save pushes cache entry back to the database, commiting any changes made by holders of the entry.

func (*CacheEntry) SetLocalHash

func (e *CacheEntry) SetLocalHash(newHash gocrypt.Hash)

SetLocalHash updates the local hash for this cache instance in memory. Changes are not pushed to the database until Save() is called.

func (*CacheEntry) SetRemoteHash

func (e *CacheEntry) SetRemoteHash(newHash gocrypt.Hash)

SetRemoteHash updates the remote hash for this cache instance in memory. Changes are not pushed to the database until Save() is called.

func (*CacheEntry) Sync

func (e *CacheEntry) Sync() *SyncInfo

Sync returns the sync associated with this cache entry.

type Change

type Change struct {
	// contains filtered or unexported fields
}

Change represents a file change on either the remote or local side of a sync It is general. The inclusion of the specific SyncInfo it belongs to allows a change processor to be shared amongst multiple syncs

func (*Change) LocalPath

func (c *Change) LocalPath() string

LocalPath returns the relative local path of the change

func (*Change) RemotePath

func (c *Change) RemotePath() string

RemotePath returns the relative remote path of the change

func (*Change) String

func (c *Change) String() string

type ChangeType

type ChangeType int

ChangeType represents the type of change which has occured. Values for this type should be one of LocalAdd, LocalDelete, LocalChange, RemoteAdd, RemoteDelete, or RemoteChange

const (
	LocalAdd ChangeType = iota
	LocalDelete
	LocalChange
	RemoteAdd
	RemoteDelete
	RemoteChange
)

Valid values for a ChangeType

type ErrCache

type ErrCache struct {
	// contains filtered or unexported fields
}

ErrCache is a universal error type for all sync issues

func (*ErrCache) Error

func (e *ErrCache) Error() string

type ErrProcessor

type ErrProcessor struct {
	Msg   string
	Inner error
}

ErrProcessor present any errors occuring change processing

func (*ErrProcessor) Error

func (e *ErrProcessor) Error() string

type ErrProtectedFile

type ErrProtectedFile struct {
	Msg   string
	Inner error
}

ErrProtectedFile represents possible errors from a protected file

func (*ErrProtectedFile) Error

func (e *ErrProtectedFile) Error() string

type ErrSync

type ErrSync struct {
	// contains filtered or unexported fields
}

ErrSync is a universal error type for all sync issues

func (*ErrSync) Error

func (e *ErrSync) Error() string
type Header struct {
	// contains filtered or unexported fields
}

A Header contains the header of an encrypted file and the metadata needed to work with that file

func CreateProtectedFile

func CreateProtectedFile(sync *SyncInfo, protFilePath string, localFilePath string) (*Header, error)

CreateProtectedFile takes the given local file and turns it into a protected file at the given remote path. All paths should be relative to metadata's respective base paths.

func OpenProtectedFile

func OpenProtectedFile(sync *SyncInfo, protFilePath string) (*Header, error)

OpenProtectedFile reads the header of the given protected file and returns the data needed to work further with that file.

func (*Header) AbsLocalPath

func (h *Header) AbsLocalPath() string

AbsLocalPath returns the local path in absolute form based on the associated sync

func (*Header) AbsRemotePath

func (h *Header) AbsRemotePath() string

AbsRemotePath returns the protected file path in absolute form, based on the associated sync.

func (*Header) ContentHash

func (h *Header) ContentHash() gocrypt.Hash

ContentHash returns the hash of the unencrypted contents of this file (ie, after extraction the file will have this hash).

func (*Header) ExtractContents

func (h *Header) ExtractContents() error

ExtractContents decrypts the contents of the protected file onto the local path

func (*Header) LocalPath

func (h *Header) LocalPath() string

LocalPath returns the path of the unprotected, decrypted version of the file

func (*Header) RemoteHash

func (h *Header) RemoteHash() (gocrypt.Hash, error)

RemoteHash returns the hash of the full protected file. This is an expensive operation, as the value is not chached.

func (*Header) RemotePath

func (h *Header) RemotePath() string

RemotePath returns the path of the protected file

func (*Header) Sync

func (h *Header) Sync() *SyncInfo

Sync returns the sync associated with this file

func (*Header) Write

func (h *Header) Write() error

Write rebuilds the protected file on disk, ensuring the contents and header are current with the local file

type SyncInfo

type SyncInfo struct {
	// contains filtered or unexported fields
}

SyncInfo stores information common to all files in a given Sync

func CreateSync

func CreateSync(localPath string, remotePath string, keys *gocrypt.KeyCombo) (sync *SyncInfo, err error)

CreateSync initializes and loads a new sync between the given local and remote paths.

func LoadSync

func LoadSync(localPath string) (*SyncInfo, error)

LoadSync loads the sync based on the settings found in localPath

func (*SyncInfo) Clean

func (s *SyncInfo) Clean() error

Clean removes unneeded temp files, database entries, etc from the sync

func (*SyncInfo) Close

func (s *SyncInfo) Close()

Close terminates any outstanding sync data in a clean way

func (*SyncInfo) ExportKeys

func (s *SyncInfo) ExportKeys(outPath, pw string) error

ExportKeys exports this sync's keys to the given path, protecting them with the given password.

func (*SyncInfo) Get

func (s *SyncInfo) Get(name string) (value string, err error)

Get retrieves the named setting from the database or "" if it cannot be found. If not found, err will be set to sql.ErrNoRows

func (*SyncInfo) GetDefault

func (s *SyncInfo) GetDefault(name string, defaultVal string) (value string, err error)

GetDefault retrieves the named setting from the database. If the setting does not exist, returns defaultVal instead

func (*SyncInfo) GetUnseenLocalEntries

func (s *SyncInfo) GetUnseenLocalEntries() (unseen *list.List, err error)

GetUnseenLocalEntries returns a list of all cache entries not marked as seen in the initial search.

func (*SyncInfo) GetUnseenRemoteEntries

func (s *SyncInfo) GetUnseenRemoteEntries() (unseen *list.List, err error)

GetUnseenRemoteEntries returns a list of all cache entries not marked as seen in the initial search.

func (*SyncInfo) ImportKeys

func (s *SyncInfo) ImportKeys(inPath, pw string) error

ImportKeys imports the keys from the given file, replacing the current keys for this sync

func (*SyncInfo) Keys

func (s *SyncInfo) Keys() gocrypt.KeyCombo

Keys returns a copy of the keys for this sync's metadata

func (*SyncInfo) LocalBase

func (s *SyncInfo) LocalBase() string

LocalBase returns the absolute path to the base directory of this sync's local (unencrypted) directory

func (*SyncInfo) MarkAllEntriesUnseen

func (s *SyncInfo) MarkAllEntriesUnseen() error

MarkAllEntriesUnseen preps for a full scan, where all cache entries have not been seen yet

func (*SyncInfo) Monitor

func (s *SyncInfo) Monitor(changes chan *Change, errors chan error, die chan bool)

Monitor begins running the entire Sync monitoring suite: checking for new changes since the last run, watching for new realtime changes, and updating files as needed. As changes are seen, they will be pushed to the changes channel. This function does not make any filesystem changes directly.

This function expects to execute as a goroutine. Using the accepted channel, passing in true will result in the monitor cleanly exiting its subcomponents.

func (*SyncInfo) ProcessChange

func (s *SyncInfo) ProcessChange()

ProcessChange notifies the sync queue monitor that changes are ready to be pulled

func (*SyncInfo) RemoteBase

func (s *SyncInfo) RemoteBase() string

RemoteBase returns the absolute path to the base directory of this sync's remote (encrypted) directory

func (*SyncInfo) Set

func (s *SyncInfo) Set(name string, value string) (previous string, err error)

Set saves the name->value setting pair into the database. If the setting already exists, it is replaced with the new value and the old value is returned. If it did not exist, "" is returned as the previous value.

type VariableScanner

type VariableScanner interface {
	Scan(...interface{}) error
}

VariableScanner covers scanning from sql.Row and sql.Rows

Jump to

Keyboard shortcuts

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