Documentation ¶
Index ¶
- type Digest
- type Dup
- type File
- type Files
- type Flag
- type Hasher
- type Index
- type Progress
- type Tree
- func (t *Tree) Dups(dirName string, maxDups, maxLost int) []*Dup
- func (t *Tree) File(name string) *File
- func (t *Tree) MarkDup(name string) error
- func (t *Tree) MarkJunk(name string) error
- func (t *Tree) MarkKeep(name string) error
- func (t *Tree) Rescan(ctx context.Context, fsys fs.FS, errFn func(error), progFn func(*Progress)) (*Index, error)
- func (t *Tree) ToIndex() *Index
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dup ¶
type Dup struct {
// contains filtered or unexported fields
}
Dup is a directory that can be deleted without losing too much data.
func (*Dup) FileMap ¶
FileMap returns a map of files in u that have copies outside u. If alt is specified, only files that have copies in alt are returned.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a regular file in the file system.
type Flag ¶
type Flag byte
Flag specifies file flags.
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is a file hasher.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is the root of an indexed file system.
func Scan ¶
func Scan(ctx context.Context, fsys fs.FS, errFn func(error), progFn func(*Progress)) (*Index, error)
Scan creates an index of fsys. If errFn is non-nil, it is called for any file-specific errors. If progFn is non-nil, it is called at regular intervals to report progress. A non-nil error is returned if ctx is canceled.
func (*Index) Overwrite ¶
Overwrite saves index contents to the specified file path. If the file already exists, it is overwritten.
func (*Index) Save ¶
Save saves index contents to the specified file path. If the file already exists, it is first renamed with a ".bak" extension.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress reports file indexing progress.
func (*Progress) Duration ¶
Duration returns the duration of the operation rounded to the nearest second.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is a directory tree representation of the index.
func (*Tree) Dups ¶
Dups returns directories under dir that contain duplicate data. If maxDups is > 0, at most that many directories are returned. maxLost is the maximum number of unique files that can be lost for a directory to still be considered a duplicate.
func (*Tree) MarkDup ¶
MarkDup sets the duplicate flag for a single file or all files under a directory. Files that are already marked are unaffected.
func (*Tree) MarkJunk ¶
MarkJunk sets the junk flag for a single file or all files under a directory. Files that are already marked are unaffected.
func (*Tree) MarkKeep ¶
MarkKeep sets the keep flag for a single file or all files under a directory. Files that are already marked are unaffected.
func (*Tree) Rescan ¶
func (t *Tree) Rescan(ctx context.Context, fsys fs.FS, errFn func(error), progFn func(*Progress)) (*Index, error)
Rescan updates the index of fsys, skipping the hashing of any files that have identical names, sizes, and modification times. See Scan for more info. Tree t should not be accessed after this operation.