Documentation ¶
Index ¶
- func CheckFileExists(file string) bool
- func InitDB(i Sqlstore) error
- type Config
- func (c *Config) Check(newRecords bool, table string, db *sql.DB) ([]StoredFileRecord, error)
- func (c *Config) CreateDB(db *sql.DB) error
- func (c *Config) CreateFile(file string) error
- func (c *Config) CreateTempTable(db *sql.DB) (string, error)
- func (c *Config) DropTempTable(table string, db *sql.DB) error
- func (c *Config) GetSqliteDB(database string) (*sql.DB, error)
- func (c *Config) ReadFileRecord(record FileRecord, table string, db *sql.DB) ([]StoredFileRecord, error)
- func (c *Config) ReadMetadata(db *sql.DB) (Metadata, error)
- func (c *Config) UpdateMetadata(db *sql.DB) error
- func (c *Config) WriteFileRecord(record FileRecord, db *sql.DB) error
- func (c *Config) WriteFileRecordTempTable(record FileRecord, db *sql.DB) error
- type FileRecord
- type Metadata
- type Sqlstore
- type StoredFileRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFileExists ¶
CheckFileExists is a reuseable function which returns true if a file exists at a known location
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the SQL DB Config object
func NewLocalStore ¶
NewLocalStore will create stuff...
func (*Config) Check ¶
Check will compare the input table to the backup location table. It always returns files that have changed their filename, filepath, etag or sha1sum. Use newRecords==true looks for new files. Use newRecords==false to look for missing/deleted files. Program needs to go through the results set to understand if file is missing/new or changed. Unoptimised for large record sets according to https://stackoverflow.com/questions/45069655/is-there-a-faster-way-to-compare-two-sqlite3-tables-in-python
func (*Config) CreateFile ¶
CreateFile will create a blank file to disk
func (*Config) CreateTempTable ¶
CreateTempTable will create and return a temporary table to store records
func (*Config) DropTempTable ¶
DropTempTable will drop the above temp table
func (*Config) GetSqliteDB ¶
GetSqliteDB returns the sql.DB object
func (*Config) ReadFileRecord ¶
func (c *Config) ReadFileRecord(record FileRecord, table string, db *sql.DB) ([]StoredFileRecord, error)
ReadFileRecord will return a set of results based on the input parameters
func (*Config) ReadMetadata ¶
ReadMetadata returns the metadata from the table
func (*Config) UpdateMetadata ¶
UpdateMetadata will simply update the metadata table. Should only be called after write to table.
func (*Config) WriteFileRecord ¶
func (c *Config) WriteFileRecord(record FileRecord, db *sql.DB) error
WriteFileRecord will write the file info to the data table
func (*Config) WriteFileRecordTempTable ¶
func (c *Config) WriteFileRecordTempTable(record FileRecord, db *sql.DB) error
WriteFileRecordTempTable will write the file info to the data table
type FileRecord ¶
FileRecord Type is what we want to update/modify
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata stores the returned metadata from the sqlstore
func (*Metadata) GetExclude ¶
GetExclude will fetch the excluded regex lookup
func (*Metadata) GetInclude ¶
GetInclude will fetch the include regex lookup
func (*Metadata) GetLastModified ¶
GetLastModified will fetch the timestamp of the last modified datetime
func (*Metadata) GetLocation ¶
GetLocation will return the internal struct location
type Sqlstore ¶
type Sqlstore interface { CreateFile(string) error CreateDB(db *sql.DB) error GetSqliteDB(string) (*sql.DB, error) UpdateMetadata(db *sql.DB) error // contains filtered or unexported methods }
Sqlstore does stuff
type StoredFileRecord ¶
type StoredFileRecord struct { FileRecord ID int Timestamp string }
StoredFileRecord is the FileRecord which is stored in the database
func AppendFileRecordIfMissing ¶
func AppendFileRecordIfMissing(slice []StoredFileRecord, fr StoredFileRecord) []StoredFileRecord
AppendFileRecordIfMissing simply adds to the array if not found