Documentation ¶
Overview ¶
Package filter controls the filtering of files
Index ¶
- Variables
- func CopyConfig(dstCtx, srcCtx context.Context) context.Context
- func GetUseFilter(ctx context.Context) bool
- func GlobToRegexp(glob string, ignoreCase bool) (*regexp.Regexp, error)
- func ReplaceConfig(ctx context.Context, f *Filter) context.Context
- func SetUseFilter(ctx context.Context, useFilter bool) context.Context
- type FilesMap
- type Filter
- func (f *Filter) Add(Include bool, glob string) error
- func (f *Filter) AddFile(file string) error
- func (f *Filter) AddRule(rule string) error
- func (f *Filter) Clear()
- func (f *Filter) DirContainsExcludeFile(ctx context.Context, fremote fs.Fs, remote string) (bool, error)
- func (f *Filter) DumpFilters() string
- func (f *Filter) Files() FilesMap
- func (f *Filter) HaveFilesFrom() bool
- func (f *Filter) InActive() bool
- func (f *Filter) Include(remote string, size int64, modTime time.Time, metadata fs.Metadata) bool
- func (f *Filter) IncludeDirectory(ctx context.Context, fs fs.Fs) func(string) (bool, error)
- func (f *Filter) IncludeObject(ctx context.Context, o fs.Object) bool
- func (f *Filter) IncludeRemote(remote string) bool
- func (f *Filter) ListContainsExcludeFile(entries fs.DirEntries) bool
- func (f *Filter) MakeListR(ctx context.Context, ...) fs.ListRFn
- func (f *Filter) UsesDirectoryFilters() bool
- type Opt
- type RulesOpt
Constants ¶
This section is empty.
Variables ¶
var DefaultOpt = Opt{ MinAge: fs.DurationOff, MaxAge: fs.DurationOff, MinSize: fs.SizeSuffix(-1), MaxSize: fs.SizeSuffix(-1), }
DefaultOpt is the default config for the filter
Functions ¶
func CopyConfig ¶
CopyConfig copies the global config (if any) from srcCtx into dstCtx returning the new context.
func GetUseFilter ¶
GetUseFilter obtains the "use filter" flag from context The flag tells filter-aware backends (Drive) to constrain List using filter
func GlobToRegexp ¶
GlobToRegexp converts an rsync style glob to a regexp
documented in filtering.md
func ReplaceConfig ¶
ReplaceConfig replaces the filter config in the ctx with the one passed in and returns a new context with that added to it.
Types ¶
type Filter ¶
type Filter struct { Opt Opt ModTimeFrom time.Time ModTimeTo time.Time // contains filtered or unexported fields }
Filter describes any filtering in operation
func AddConfig ¶
AddConfig returns a mutable config structure based on a shallow copy of that found in ctx and returns a new context with that added to it.
func NewFilter ¶
NewFilter parses the command line options and creates a Filter object. If opt is nil, then DefaultOpt will be used
func (*Filter) AddRule ¶
AddRule adds a filter rule with include/exclude indicated by the prefix
These are
- glob
- glob !
'+' includes the glob, '-' excludes it and '!' resets the filter list
Line comments may be introduced with '#' or ';'
func (*Filter) DirContainsExcludeFile ¶
func (f *Filter) DirContainsExcludeFile(ctx context.Context, fremote fs.Fs, remote string) (bool, error)
DirContainsExcludeFile checks if exclude file is present in a directory. If fs is nil, it works properly if ExcludeFile is an empty string (for testing).
func (*Filter) DumpFilters ¶
DumpFilters dumps the filters in textual form, 1 per line
func (*Filter) Files ¶
Files returns all the files from the `--files-from` list
It may be nil if the list is empty
func (*Filter) HaveFilesFrom ¶
HaveFilesFrom returns true if --files-from has been supplied
func (*Filter) Include ¶
Include returns whether this object should be included into the sync or not and logs the reason for exclusion if not included
func (*Filter) IncludeDirectory ¶
IncludeDirectory returns a function which checks whether this directory should be included in the sync or not.
func (*Filter) IncludeObject ¶
IncludeObject returns whether this object should be included into the sync or not. This is a convenience function to avoid calling o.ModTime(), which is an expensive operation.
func (*Filter) IncludeRemote ¶
IncludeRemote returns whether this remote passes the filter rules.
func (*Filter) ListContainsExcludeFile ¶
func (f *Filter) ListContainsExcludeFile(entries fs.DirEntries) bool
ListContainsExcludeFile checks if exclude file is present in the list.
func (*Filter) MakeListR ¶
func (f *Filter) MakeListR(ctx context.Context, NewObject func(ctx context.Context, remote string) (fs.Object, error)) fs.ListRFn
MakeListR makes function to return all the files set using --files-from
func (*Filter) UsesDirectoryFilters ¶
UsesDirectoryFilters returns true if the filter uses directory filters and false if it doesn't.
This is used in deciding whether to walk directories or use ListR
type Opt ¶
type Opt struct { DeleteExcluded bool RulesOpt // embedded so we don't change the JSON API ExcludeFile []string FilesFrom []string FilesFromRaw []string MetaRules RulesOpt MinAge fs.Duration MaxAge fs.Duration MinSize fs.SizeSuffix MaxSize fs.SizeSuffix IgnoreCase bool }
Opt configures the filter
Directories ¶
Path | Synopsis |
---|---|
Package filterflags implements command line flags to set up a filter
|
Package filterflags implements command line flags to set up a filter |