Documentation ¶
Index ¶
- Constants
- func WalkFileTypeStatsDB(scanDirs []string, dbfile string) (types.FileTypeStats, error)
- type TDirMonitor
- type TDirMonitors
- func (dm *TDirMonitors) AddDir(dir string, recursive bool, handler notifywatch.NotifyHandlerFun, ...) *TDirMonitor
- func (dm *TDirMonitors) Contains(dir string) bool
- func (dm *TDirMonitors) Dirs() []string
- func (dm *TDirMonitors) IsDirty(dir string) bool
- func (dm *TDirMonitors) RemoveDir(dir string) error
- func (dm *TDirMonitors) RemoveDirs(dirs ...string) error
- func (dm *TDirMonitors) ScanFinish(dir string)
- func (dm *TDirMonitors) ScanFinished(dir string) time.Time
- func (dm *TDirMonitors) ScanRunning(dir string) bool
- func (dm *TDirMonitors) ScanStart(dir string)
- func (dm *TDirMonitors) ScanStarted(dir string) time.Time
- func (dm *TDirMonitors) Status() *TDirMonitorsStatus
- type TDirMonitorsStatus
- type TreeStatsWatcher
- func (tsw *TreeStatsWatcher) AddWatch(dirs ...string) error
- func (tsw *TreeStatsWatcher) ScanAllSync() error
- func (tsw *TreeStatsWatcher) ScanDir(dir string) error
- func (tsw *TreeStatsWatcher) ScanDirAsync(dir string) error
- func (tsw *TreeStatsWatcher) ScanDurationLast() time.Duration
- func (tsw *TreeStatsWatcher) StartWatcher(dir string) error
- func (tsw *TreeStatsWatcher) StopWatchAll() error
- func (tsw *TreeStatsWatcher) StopWatcher(dir string) error
- func (tsw *TreeStatsWatcher) WatchAll() error
Constants ¶
const Version = "v0.8.0"
Version exposes the current package version.
Variables ¶
This section is empty.
Functions ¶
func WalkFileTypeStatsDB ¶
func WalkFileTypeStatsDB(scanDirs []string, dbfile string) (types.FileTypeStats, error)
Types ¶
type TDirMonitor ¶
type TDirMonitor struct { notifywatch.NotifyWatcher // embed NotifyWatcher, because TDirMonitor is just a Watcer with added state and access/info methods // contains filtered or unexported fields }
type TDirMonitors ¶
type TDirMonitors map[string]*TDirMonitor
func (*TDirMonitors) AddDir ¶
func (dm *TDirMonitors) AddDir(dir string, recursive bool, handler notifywatch.NotifyHandlerFun, events ...notify.Event) *TDirMonitor
AddDir adds dir to the DirMonitors collection with a new DirMonitor instance, while removing all overlapping dirs
func (*TDirMonitors) Contains ¶
func (dm *TDirMonitors) Contains(dir string) bool
Contains returns whether dir is contained in the registered dirs
func (*TDirMonitors) Dirs ¶
func (dm *TDirMonitors) Dirs() []string
Dirs returns a slice of all registered dirs
func (*TDirMonitors) IsDirty ¶
func (dm *TDirMonitors) IsDirty(dir string) bool
IsDirty reports dirty status, i.e. if the DB for dir is up to date or being updated
func (*TDirMonitors) RemoveDir ¶
func (dm *TDirMonitors) RemoveDir(dir string) error
RemoveDir removes dir from the container
func (*TDirMonitors) RemoveDirs ¶
func (dm *TDirMonitors) RemoveDirs(dirs ...string) error
RemoveDirs removes dirs from the container
func (*TDirMonitors) ScanFinish ¶
func (dm *TDirMonitors) ScanFinish(dir string)
ScanFinish updates finished time for dir
func (*TDirMonitors) ScanFinished ¶
func (dm *TDirMonitors) ScanFinished(dir string) time.Time
ScanFinished returns the time the last scan was started
func (*TDirMonitors) ScanRunning ¶
func (dm *TDirMonitors) ScanRunning(dir string) bool
ScanRunning reports whether a ssscan on dir is currently running
func (*TDirMonitors) ScanStart ¶
func (dm *TDirMonitors) ScanStart(dir string)
ScanFinish updates start time for dir
func (*TDirMonitors) ScanStarted ¶
func (dm *TDirMonitors) ScanStarted(dir string) time.Time
ScanStarted returns the time the last scan was started
func (*TDirMonitors) Status ¶
func (dm *TDirMonitors) Status() *TDirMonitorsStatus
type TDirMonitorsStatus ¶
type TreeStatsWatcher ¶
type TreeStatsWatcher struct { TDirMonitors // embed this map, because a TreeStatsWatcher is just TDirMonitors with added state // contains filtered or unexported fields }
func NewTreeStatsWatcher ¶
func NewTreeStatsWatcher(dirs []string, dbconn *ftsdb.FileTypeStatsDB) (*TreeStatsWatcher, error)
NewTreeStatsWatcher is the top level constructor featuring:
- a recursive watcher and scanner for all files in the given param dirs
- a sqlite DB session (param database: file name)
An instance is always returned, even if an error occurred dirs will be trimmed of trailing suffixes and evaluated recursively If dirs is empty, you can add watches later with AddWatch() or AddDir()
func (*TreeStatsWatcher) AddWatch ¶
func (tsw *TreeStatsWatcher) AddWatch(dirs ...string) error
AddWatch adds a (default) watch for the given dirs Default means: recursive and for events notify.InCreate, notify.InModify, notify.InMovedFrom, notify.InMovedTo, notify.Remove For a customised watch, use AddDir()
func (*TreeStatsWatcher) ScanAllSync ¶
func (tsw *TreeStatsWatcher) ScanAllSync() error
ScanSync does a full scan over all registered dirs synchronously and updates the database This can take a long time (minutes to hours) to complete
func (*TreeStatsWatcher) ScanDir ¶
func (tsw *TreeStatsWatcher) ScanDir(dir string) error
scanDir scans the given dir recursively and updates the database This can take a long time (minutes to hours) to complete
func (*TreeStatsWatcher) ScanDirAsync ¶
func (tsw *TreeStatsWatcher) ScanDirAsync(dir string) error
ScanDirAsync scans dir asynchronously TODO: add channel to make interuption possible?
func (*TreeStatsWatcher) ScanDurationLast ¶
func (tsw *TreeStatsWatcher) ScanDurationLast() time.Duration
func (*TreeStatsWatcher) StartWatcher ¶
func (tsw *TreeStatsWatcher) StartWatcher(dir string) error
StartWatcher starts the dir watcher in the background (or returns an error if not available)
func (*TreeStatsWatcher) StopWatchAll ¶
func (tsw *TreeStatsWatcher) StopWatchAll() error
StopAll stops all registered dirs with the notify watcher
func (*TreeStatsWatcher) StopWatcher ¶
func (tsw *TreeStatsWatcher) StopWatcher(dir string) error
StopWatcher stops and removes the watcher for dir (The DirMonitor is removed entirely, because we have no way to re-start a stopped watcher, so its existence becomes meaningless after stopping)
func (*TreeStatsWatcher) WatchAll ¶
func (tsw *TreeStatsWatcher) WatchAll() error
WatchAll starts all registered dirs with the notify watcher (ignoring already started ones)