Documentation ¶
Index ¶
- type EntryMutations
- type FSDriver
- type FSEntry
- type FSInfo
- type FSMutation
- type FSMutations
- type FSName
- type Migrator
- type MutationType
- type Options
- type PairName
- type SQLite3
- func (s *SQLite3) AddNewFileSystemEntries(ctx context.Context, opts ...Options) (chan<- FSEntry, <-chan error)
- func (s *SQLite3) Close() error
- func (s *SQLite3) DeleteVersionNew(ctx context.Context, fsName FSName) error
- func (s *SQLite3) FindSyncPeers(ctx context.Context, fsName FSName) ([]FSName, error)
- func (s *SQLite3) GetFileSystemInfo(ctx context.Context, fsName FSName) (*FSInfo, error)
- func (s *SQLite3) GetFileSystemMutations(ctx context.Context, fsName FSName) (FSMutations, error)
- func (s *SQLite3) GetLatestFileSystemEntries(ctx context.Context, fsName FSName) ([]FSEntry, error)
- func (s *SQLite3) GetPCloudVsLocalMutations(ctx context.Context) (FSMutations, error)
- func (s *SQLite3) GetPreviousFileSystemEntries(ctx context.Context, fsName FSName) ([]FSEntry, error)
- func (s *SQLite3) GetSyncDetails(ctx context.Context, fsName FSName) (FSDriver, string, error)
- func (s *SQLite3) IsFileSystemEmpty(ctx context.Context, fsName FSName) (bool, error)
- func (s *SQLite3) MarkFileSystemAsChanged(ctx context.Context, fsName FSName) error
- func (s *SQLite3) MarkSyncAsChanged(ctx context.Context, fsName FSName) error
- func (s *SQLite3) MarkSyncComplete(ctx context.Context, fsName FSName) error
- func (s *SQLite3) MarkSyncInProgress(ctx context.Context, fsName FSName) error
- func (s *SQLite3) RotateFileSystemVersions(ctx context.Context, fsName FSName) error
- type SyncPair
- type SyncStatus
- type Version
- type VersionedEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntryMutations ¶
type EntryMutations []VersionedEntry
EntryMutations contains the details of the mutation of an entry. There will be only one entry in the case of a Creation or a Deletion. There will be 2 entries in the case of an Update or a Modification, in which case the first entry will be the "from" state and the second will be the "to" state.
type FSEntry ¶
type FSEntry struct { FSName FSName DeviceID string // for cloud, this could be used to distinguish multiple accounts on the same cloud provider EntryID uint64 IsFolder bool Path string Name string ParentFolderID uint64 Created time.Time Modified time.Time Size uint64 Hash string }
FSEntry is a set of details about an entry (folder or file) in the file system.
type FSMutation ¶
type FSMutation struct { Type MutationType Details EntryMutations }
FSMutation contains a file system mutation: type and details.
type FSMutations ¶
type FSMutations []FSMutation
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
NewMigrator creates a new initialised Migrator struct.
type MutationType ¶
type MutationType string
MutationType describes the type of mutation of a file system.
const ( // MutationTypeDeleted means a deletion on the file system. MutationTypeDeleted MutationType = "deleted" // MutationTypeCreated means a creation on the file system. MutationTypeCreated MutationType = "created" // MutationTypeModified means a file content modification on the file system. MutationTypeModified MutationType = "modified" // MutationTypeMoved means a file move on the file system. MutationTypeMoved MutationType = "moved" )
type Options ¶
type Options func(*config)
Options defines the signature of a functional parameter for AddNewFileSystemEntries.
func WithEntriesChannelSize ¶
WithEntriesChannelSize is a functional parameter that allows to choose the size of the entries channel used by AddNewFileSystemEntries.
type SQLite3 ¶
type SQLite3 struct {
// contains filtered or unexported fields
}
SQLite3 is a sqlite3 database store.
func NewSQLite3 ¶
NewSQLite3 creates a new initialised SQLite3.
func (*SQLite3) AddNewFileSystemEntries ¶
func (s *SQLite3) AddNewFileSystemEntries(ctx context.Context, opts ...Options) (chan<- FSEntry, <-chan error)
AddNewFileSystemEntries adds a new file system entry. It returns two channels: - the first is used to supply data to this method - the second is a channel of error type should this function encounter an error. Refer to tests and main code for example uses.
func (*SQLite3) DeleteVersionNew ¶
DeleteVersionNew removes "new" file system entries for the specified file system. This would be performed with a view to load a new "VersionNew" set, in replacement.
func (*SQLite3) FindSyncPeers ¶
func (*SQLite3) GetFileSystemInfo ¶
GetFileSystemInfo returns high level information about the file system fsName. It will return an error (no rows found) if it cannot find the status row.
func (*SQLite3) GetFileSystemMutations ¶
GetFileSystemMutations returns a slice of mutations for the specified file system. It should be noted that up to two rows may be created: one for each version: previous and new.
func (*SQLite3) GetLatestFileSystemEntries ¶
GetLatestFileSystemEntries get the latest (i.e. version "New") file system entries for the specified file system type.
func (*SQLite3) GetPCloudVsLocalMutations ¶
func (s *SQLite3) GetPCloudVsLocalMutations(ctx context.Context) (FSMutations, error)
GetPCloudVsLocalMutations returns a slice of mutations that exist between the pCloud file system and the local file system.
func (*SQLite3) GetPreviousFileSystemEntries ¶
func (s *SQLite3) GetPreviousFileSystemEntries(ctx context.Context, fsName FSName) ([]FSEntry, error)
GetPreviousFileSystemEntries get the previous (i.e. version "Previous") file system entries for the specified file system type.
func (*SQLite3) GetSyncDetails ¶
GetSyncDetails returns the driver for the specified file system name and the root path.
func (*SQLite3) IsFileSystemEmpty ¶
IsFileSystemEmpty returns true if no entry data exists at all in the database for `fsName`, otherwise it returns false.
func (*SQLite3) MarkFileSystemAsChanged ¶
MarkFileSystemAsChanged marks the status of the file system as "changed". This also triggers the internal refresh of all staging tables.
func (*SQLite3) MarkSyncAsChanged ¶
MarkSyncAsChanged marks the status of the sync as "changed". This also triggers the internal refresh of all staging tables.
func (*SQLite3) MarkSyncComplete ¶
MarkSyncComplete marks the status of the sync as "complete". TODO: it may be that the staging table should be cleared down, although not essential because that is properly taken care of by other methods that change the state of table "filesystem".
func (*SQLite3) MarkSyncInProgress ¶
MarkSyncInProgress marks the status of the sync as "in progress".
type SyncStatus ¶
type SyncStatus string
SyncStatus defines the status of the sync. It is used to prevent refreshing data in the filesystem table when it has not yet been completely sync'ed. In particular, VersionPrevious should not be replaced with new data until the sync has completed or some delta changes between "previous" and "new" will be lost and non-replicated. This should not be confused with the sync that takes place across filesystems (such as cloud vs local) which only involves VersionNew of each filesystems. It is always safe to update VersionNew (but not VersionPrevious until processed).
const ( // SyncStatusComplete indicates VersionPrevious has been completely sync'ed and can now be // replaced with newer data. SyncStatusComplete SyncStatus = "Complete" // SyncStatusRequired indicates VersionPrevious has just been refreshed and requires // sync'ing against VersionNew. SyncStatusRequired SyncStatus = "Required" // SyncStatusInProgress indicates that the sync between VersionPrevious and VersionNew is in // progress. SyncStatusInProgress SyncStatus = "In progress" )
type Version ¶
type Version string
Version is used to distinguish the two entry-sets of file system data in the database.