Documentation ¶
Index ¶
- Constants
- func ChangeQueueManager(newChanges chan *Change, completedChanges chan *Change, errors chan error, ...)
- func GetFreeRemotePath(s *SyncInfo) (path string, err error)
- type CacheEntry
- func (e *CacheEntry) AbsLocalPath() string
- func (e *CacheEntry) AbsRemotePath() string
- func (e *CacheEntry) Delete() error
- func (e *CacheEntry) LocalHash() gocrypt.Hash
- func (e *CacheEntry) LocalPath() string
- func (e *CacheEntry) MarkLocalSeen() error
- func (e *CacheEntry) MarkRemoteSeen() error
- func (e *CacheEntry) RemoteHash() gocrypt.Hash
- func (e *CacheEntry) RemotePath() string
- func (e *CacheEntry) Save() error
- func (e *CacheEntry) SetLocalHash(newHash gocrypt.Hash)
- func (e *CacheEntry) SetRemoteHash(newHash gocrypt.Hash)
- func (e *CacheEntry) Sync() *SyncInfo
- type Change
- type ChangeType
- type ErrCache
- type ErrProcessor
- type ErrProtectedFile
- type ErrSync
- type Header
- func (h *Header) AbsLocalPath() string
- func (h *Header) AbsRemotePath() string
- func (h *Header) ContentHash() gocrypt.Hash
- func (h *Header) ExtractContents() error
- func (h *Header) LocalPath() string
- func (h *Header) RemoteHash() (gocrypt.Hash, error)
- func (h *Header) RemotePath() string
- func (h *Header) Sync() *SyncInfo
- func (h *Header) Write() error
- type SyncInfo
- func (s *SyncInfo) Clean() error
- func (s *SyncInfo) Close()
- func (s *SyncInfo) ExportKeys(outPath, pw string) error
- func (s *SyncInfo) Get(name string) (value string, err error)
- func (s *SyncInfo) GetDefault(name string, defaultVal string) (value string, err error)
- func (s *SyncInfo) GetUnseenLocalEntries() (unseen *list.List, err error)
- func (s *SyncInfo) GetUnseenRemoteEntries() (unseen *list.List, err error)
- func (s *SyncInfo) ImportKeys(inPath, pw string) error
- func (s *SyncInfo) Keys() gocrypt.KeyCombo
- func (s *SyncInfo) LocalBase() string
- func (s *SyncInfo) MarkAllEntriesUnseen() error
- func (s *SyncInfo) Monitor(changes chan *Change, errors chan error, die chan bool)
- func (s *SyncInfo) ProcessChange()
- func (s *SyncInfo) RemoteBase() string
- func (s *SyncInfo) Set(name string, value string) (previous string, err error)
- type VariableScanner
Constants ¶
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 ¶
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) RemotePath ¶
RemotePath returns the relative remote path of the change
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
type ErrProcessor ¶
ErrProcessor present any errors occuring change processing
func (*ErrProcessor) Error ¶
func (e *ErrProcessor) Error() string
type ErrProtectedFile ¶
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
type Header ¶
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 ¶
OpenProtectedFile reads the header of the given protected file and returns the data needed to work further with that file.
func (*Header) AbsLocalPath ¶
AbsLocalPath returns the local path in absolute form based on the associated sync
func (*Header) AbsRemotePath ¶
AbsRemotePath returns the protected file path in absolute form, based on the associated sync.
func (*Header) ContentHash ¶
ContentHash returns the hash of the unencrypted contents of this file (ie, after extraction the file will have this hash).
func (*Header) ExtractContents ¶
ExtractContents decrypts the contents of the protected file onto the local path
func (*Header) LocalPath ¶
LocalPath returns the path of the unprotected, decrypted version of the file
func (*Header) RemoteHash ¶
RemoteHash returns the hash of the full protected file. This is an expensive operation, as the value is not chached.
func (*Header) RemotePath ¶
RemotePath returns the path of the protected 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 (*SyncInfo) Close ¶
func (s *SyncInfo) Close()
Close terminates any outstanding sync data in a clean way
func (*SyncInfo) ExportKeys ¶
ExportKeys exports this sync's keys to the given path, protecting them with the given password.
func (*SyncInfo) Get ¶
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 ¶
GetDefault retrieves the named setting from the database. If the setting does not exist, returns defaultVal instead
func (*SyncInfo) GetUnseenLocalEntries ¶
GetUnseenLocalEntries returns a list of all cache entries not marked as seen in the initial search.
func (*SyncInfo) GetUnseenRemoteEntries ¶
GetUnseenRemoteEntries returns a list of all cache entries not marked as seen in the initial search.
func (*SyncInfo) ImportKeys ¶
ImportKeys imports the keys from the given file, replacing the current keys for this sync
func (*SyncInfo) LocalBase ¶
LocalBase returns the absolute path to the base directory of this sync's local (unencrypted) directory
func (*SyncInfo) MarkAllEntriesUnseen ¶
MarkAllEntriesUnseen preps for a full scan, where all cache entries have not been seen yet
func (*SyncInfo) Monitor ¶
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 ¶
RemoteBase returns the absolute path to the base directory of this sync's remote (encrypted) directory
type VariableScanner ¶
type VariableScanner interface {
Scan(...interface{}) error
}
VariableScanner covers scanning from sql.Row and sql.Rows