Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateAncestorsFromName(root string, name string) []string
- func FileIdFromName(rootGroup string, name string) string
- func NormalizeFileName(root string, name string) string
- func ParseFilter(spec interface{}, fmtvalues ...interface{}) (*filter.Filter, error)
- type DB
- func (self *DB) AddGlobalExclusions(patterns ...string)
- func (self *DB) Cleanup(skipFileStats bool, skipRootGroupPrune bool) error
- func (self *DB) GetDirectoriesByFile(filename string) []Group
- func (self *DB) GetPivotDatabase() backends.Backend
- func (self *DB) GetPivotMetadataDatabase() backends.Backend
- func (self *DB) Initialize() error
- func (self *DB) Model(name string) (mapper.Mapper, bool)
- func (self *DB) PollDirectories()
- func (self *DB) RegisterModel(schema *dal.Collection, _db ...backends.Backend) error
- func (self *DB) RegisterPostScanEvent(fn PostScanFunc)
- func (self *DB) Scan(deep bool, labels ...string) error
- func (self *DB) UnregisterModel(name string)
- type Entry
- func (self *Entry) Children(filterString ...string) ([]*Entry, error)
- func (self *Entry) GenerateChecksum(forceRecalculate bool) (string, error)
- func (self *Entry) Get(key string, fallback ...interface{}) interface{}
- func (self *Entry) GetAbsolutePath() (string, error)
- func (self *Entry) GetHumanSize(format string) string
- func (self *Entry) GetManifest(fields []string, filterString string) (*Manifest, error)
- func (self *Entry) Info() os.FileInfo
- func (self *Entry) LastModifiedTime() time.Time
- func (self *Entry) LoadAllMetadata() error
- func (self *Entry) LoadMetadata(pass int) error
- func (self *Entry) String() string
- func (self *Entry) Walk(walkFn WalkFunc, filterStrings ...string) error
- type Group
- func (self *Group) ContainsPath(absPath string) bool
- func (self *Group) GetAncestors() []string
- func (self *Group) GetLatestModifyTime() (time.Time, error)
- func (self *Group) GetParentFromPath(relPath string) (string, error)
- func (self *Group) Initialize() error
- func (self *Group) RefreshStats() error
- func (self *Group) Scan(subgroups []string) error
- func (self *Group) ScanPath(absPath string) error
- func (self *Group) WalkModifiedSince(lastModifiedAt time.Time, entryFn WalkEntryFunc) error
- type GroupListFunc
- type GroupSet
- type Manifest
- type ManifestItem
- type ManifestItemType
- type ManifestValue
- type PopulateGroupFunc
- type PostInitializeFunc
- type PostScanFunc
- type PreInitializeFunc
- type SyncPolicy
- type WalkEntryFunc
- type WalkFunc
Constants ¶
View Source
const FileFingerprintSize = 16777216
Variables ¶
View Source
var ChecksumPolicy = SyncPolicy{ Fields: []string{`checksum`}, }
View Source
var CleanupIterations = 256
View Source
var DefaultBaseDirectory = `~/.config/metabase`
View Source
var DefaultGlobalExclusions = []string{
`._.DS_Store`,
`._.Trashes`,
`.DS_Store`,
`.Spotlight-V100`,
`.Trashes`,
`desktop.ini`,
`lost+found`,
`Thumbs.db`,
}
View Source
var DefaultManifestFields = []string{`id`, `relative_path`, `type`}
View Source
var MaxChildEntries = 10000
View Source
var MaxTimeBetweenDeepScans = time.Duration(0)
View Source
var Metadata mapper.Mapper
View Source
var MetadataEncoding = base32.NewEncoding(`abcdefghijklmnopqrstuvwxyz234567`)
View Source
var MetadataSchema = &dal.Collection{ Name: `metadata`, IdentityFieldType: dal.StringType, Fields: []dal.Field{ { Name: `name`, Type: dal.StringType, Required: true, }, { Name: `parent`, Type: dal.StringType, Required: true, }, { Name: `type`, Type: dal.StringType, }, { Name: `size`, Type: dal.IntType, Validator: dal.ValidatePositiveOrZeroInteger, }, { Name: `checksum`, Type: dal.StringType, }, { Name: `root_group`, Type: dal.StringType, Required: true, }, { Name: `group`, Type: dal.BooleanType, Required: true, }, { Name: `children`, Type: dal.IntType, Validator: dal.ValidatePositiveOrZeroInteger, }, { Name: `descendants`, Type: dal.IntType, }, { Name: `last_modified_at`, Type: dal.IntType, Required: true, }, { Name: `last_deep_scanned_at`, Type: dal.IntType, }, { Name: `created_at`, Type: dal.IntType, Required: true, DefaultValue: time.Now, }, { Name: `metadata`, Type: dal.ObjectType, }, }, }
View Source
var PopulateGroup = func(group *Group) error { if group.ID == `` && group.Path != `` { group.ID = path.Base(group.Path) } if group.RootPath == `` { group.RootPath = group.Path } group.RootPath = strings.TrimSuffix(group.RootPath, `/`) if group.Parent == `` { group.Parent = RootGroupName } return nil }
View Source
var RootGroupName = `root`
View Source
var SearchIndexFlushEveryNRecords = 1000
View Source
var SkipEntry = errors.New("skip entry")
Functions ¶
func FileIdFromName ¶
func NormalizeFileName ¶
func ParseFilter ¶
Types ¶
type DB ¶
type DB struct { BaseDirectory string `json:"base_dir"` AutomigrateModels bool `json:"automigrate"` URI string `json:"uri,omitempty"` Indexer string `json:"indexer,omitempty"` MetadataURI string `json:"metadata_uri,omitempty"` MetadataIndexer string `json:"metadata_indexer,omitempty"` AdditionalIndexers []string `json:"additional_indexers,omitempty"` GlobalExclusions []string `json:"global_exclusions,omitempty"` ScanInProgress bool `json:"scan_in_progress"` ExtractFields []string `json:"extract_fields,omitempty"` SkipMigrate bool `json:"skip_migrate"` SkipChecksum bool `json:"skip_checksum"` StatsDatabase string `json:"stats_database"` StatsTags map[string]interface{} `json:"stats_tags"` GroupLister GroupListFunc `json:"-"` ScanInterval string `json:"scan_interval"` PreInitialize PreInitializeFunc `json:"-"` PostInitialize PostInitializeFunc `json:"-"` // contains filtered or unexported fields }
var Instance *DB
func (*DB) AddGlobalExclusions ¶
func (*DB) GetDirectoriesByFile ¶
func (*DB) GetPivotDatabase ¶
func (*DB) GetPivotMetadataDatabase ¶
func (*DB) Initialize ¶
Initialize the DB by opening the underlying database
func (*DB) PollDirectories ¶
func (self *DB) PollDirectories()
func (*DB) RegisterModel ¶
func (*DB) RegisterPostScanEvent ¶
func (self *DB) RegisterPostScanEvent(fn PostScanFunc)
func (*DB) UnregisterModel ¶
type Entry ¶
type Entry struct { ID string `json:"id"` RelativePath string `json:"name"` Type string `json:"type"` Parent string `json:"parent,omitempty"` Checksum string `json:"checksum,omitempty"` Size int64 `json:"size,omitempty"` RootGroup string `json:"root_group"` IsGroup bool `json:"group"` ChildCount int `json:"children"` DescendantCount int `json:"descendants"` LastModifiedAt int64 `json:"last_modified_at,omitempty"` LastDeepScannedAt int64 `json:"last_deep_scanned_at,omitempty"` CreatedAt int64 `json:"created_at,omitempty"` Metadata map[string]interface{} `json:"metadata"` InitialPath string `json:"-"` // contains filtered or unexported fields }
func (*Entry) GenerateChecksum ¶
func (*Entry) GetAbsolutePath ¶
func (*Entry) GetHumanSize ¶
func (*Entry) GetManifest ¶
func (*Entry) LastModifiedTime ¶
func (*Entry) LoadAllMetadata ¶
func (*Entry) LoadMetadata ¶
type Group ¶
type Group struct { ID string `json:"id"` Path string `json:"path"` Parent string `json:"parent"` RootPath string `json:"-"` FilePattern string `json:"file_pattern,omitempty"` NoRecurseDirectories bool `json:"no_recurse"` FollowSymlinks bool `json:"follow_symlinks"` FileMinimumSize int `json:"min_file_size,omitempty"` DeepScan bool `json:"deep_scan"` SkipChecksum bool `json:"skip_checksum"` CurrentPass int `json:"-"` PassesDone int `json:"-"` TargetSubgroups []string `json:"-"` FileCount int `json:"file_count"` ModifiedFileCount int `json:"modified_file_count"` Properties map[string]interface{} `json:"properties,omitempty"` // contains filtered or unexported fields }
func (*Group) ContainsPath ¶
func (*Group) GetAncestors ¶
func (*Group) GetParentFromPath ¶
func (*Group) Initialize ¶
func (*Group) RefreshStats ¶
func (*Group) WalkModifiedSince ¶
func (self *Group) WalkModifiedSince(lastModifiedAt time.Time, entryFn WalkEntryFunc) error
type GroupListFunc ¶
type Manifest ¶
type Manifest struct { BaseDirectory string Items []ManifestItem Fields []string }
func NewManifest ¶
func (*Manifest) Add ¶
func (self *Manifest) Add(items ...ManifestItem)
func (*Manifest) GetUpdateManifest ¶
func (self *Manifest) GetUpdateManifest(policy SyncPolicy) (*Manifest, error)
type ManifestItem ¶
type ManifestItem struct { ID string Type ManifestItemType Label string RelativePath string Values []ManifestValue }
func (*ManifestItem) NeedsUpdate ¶
func (self *ManifestItem) NeedsUpdate(manifest *Manifest, policy *SyncPolicy) (bool, error)
type ManifestItemType ¶
type ManifestItemType string
const ( FileItem ManifestItemType = `file` DirectoryItem = `directory` )
type ManifestValue ¶
type ManifestValue interface{}
type PopulateGroupFunc ¶
type PostScanFunc ¶
type PostScanFunc func()
type PreInitializeFunc ¶
type SyncPolicy ¶
func (*SyncPolicy) Compare ¶
func (self *SyncPolicy) Compare(field string, value interface{}, other interface{}) bool
type WalkEntryFunc ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.