ignorefs

package
v0.3.0-pre5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ignorefs implements a wrapper that hides ignored files listed in '.kopiaignore' and in policies attached to directories.

Index

Constants

This section is empty.

Variables

View Source
var DefaultFilesPolicy = FilesPolicy{
	DotIgnoreFiles: []string{".kopiaignore"},
}

DefaultFilesPolicy is the default file ignore policy.

Functions

func New

func New(dir fs.Directory, policyGetter FilesPolicyGetter, options ...Option) fs.Directory

New returns a fs.Directory that wraps another fs.Directory and hides files specified in the ignore dotfiles.

Types

type FilesPolicy

type FilesPolicy struct {
	IgnoreRules         []string `json:"ignore,omitempty"`
	NoParentIgnoreRules bool     `json:"noParentIgnore,omitempty"`

	DotIgnoreFiles         []string `json:"ignoreDotFiles,omitempty"`
	NoParentDotIgnoreFiles bool     `json:"noParentDotFiles,omitempty"`

	MaxFileSize int64 `json:"maxFileSize,omitempty"`
}

FilesPolicy describes files to be ignored when taking snapshots.

func (*FilesPolicy) Merge

func (p *FilesPolicy) Merge(src FilesPolicy)

Merge applies default values from the provided policy.

type FilesPolicyGetter

type FilesPolicyGetter interface {
	GetPolicyForPath(relativePath string) (*FilesPolicy, error)
}

FilesPolicyGetter fetches FilesPolicy for a path relative to the root of the filesystem. relativePath always starts with "." and path elements are separated with "/".

type FilesPolicyMap

type FilesPolicyMap map[string]*FilesPolicy

FilesPolicyMap implements FilesPolicyGetter for a static mapping of relative paths to FilesPolicy.

func (FilesPolicyMap) GetPolicyForPath

func (m FilesPolicyMap) GetPolicyForPath(relativePath string) (*FilesPolicy, error)

GetPolicyForPath returns FilePolicy defined in the map or nil.

type IgnoreCallback

type IgnoreCallback func(path string, metadata fs.Entry)

IgnoreCallback is a function called by ignorefs to report whenever a file or directory is being ignored while listing its parent.

type Option

type Option func(parentContext *ignoreContext)

Option modifies the behavior of ignorefs

func ReportIgnoredFiles

func ReportIgnoredFiles(f IgnoreCallback) Option

ReportIgnoredFiles returns an Option causing ignorefs to call the provided function whenever a file or directory is ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL