dupe

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

© Ben Garrett https://github.com/bengarrett/dupers

Index

Constants

View Source
const (
	WinOS = "windows"
)

Variables

View Source
var (
	ErrFileEmpty     = errors.New("file is empty, being 0 byte in size")
	ErrNilConfig     = errors.New("config cannot be nil")
	ErrNoMatch       = errors.New("no match found")
	ErrNoNamedBucket = errors.New("a named bucket is required")
	ErrPathEmpty     = errors.New("path is empty")
	ErrPathIsFile    = errors.New("path is a file")
	ErrPathExist     = errors.New("path exists in the database bucket")
	ErrPathNoFound   = errors.New("path does not exist")
)

Functions

func Bucket

func Bucket(name string) parse.Bucket

Bucket returns the named string as a Bucket type.

func Match

func Match(path, match string) string

Match prints 'Found duplicate match'.

func Print

func Print(quiet, exact bool, term string, m *database.Matches) string

Print the results of the database comparisons.

func PrintRM

func PrintRM(path string, err error) string

PrintRM prints "could not remove:".

func PrintWalk

func PrintWalk(lookup bool, c *Config) string

PrintWalk prints "Scanning/Looking up".

func Removes

func Removes(w io.Writer, root string, files []fs.DirEntry) ([]string, error)

Removes directories that do not contain MS-DOS or Windows programs. The strings contains the path of any undeletable files.

func SkipDirs

func SkipDirs(name string) error

SkipDirs tells WalkDir to ignore specific system and hidden directories.

func SkipFS

func SkipFS(dir, file, regular bool, d fs.DirEntry) error

SkipFS tells WalkDir to ignore specific files and directories. A true dir value will skip directories. A true file value will skip OS specific system files. A true regular value will skip all non-files such as symlinks.

func SkipFile

func SkipFile(name string) bool

SkipFile returns true if the file matches a known Windows or macOS system file.

Types

type Config

type Config struct {
	Debug bool // Debug spams technobabble to stdout.
	Quiet bool // Quiet the feedback sent to stdout.
	Yes   bool // Yes is assumed for all user questions and prompts.
	Test  bool // Test toggles the internal unit test mode.
	parse.Scanner
}

Config options.

func (*Config) Check

func (c *Config) Check(name string) (isdir bool, path string, err error)

Check stats and returns the named file or directory. If it does not exist, it looks up an absolute path and returns the result. If the item is a file it returns both the named file and an ErrPathIsFile error.

func (*Config) Checksum

func (c *Config) Checksum(db *bolt.DB, name, bucket string) error

Checksum the named file and save it to the bucket.

func (*Config) Clean

func (c *Config) Clean(w io.Writer) error

Clean removes all empty directories from c.Source. Directories containing hidden system directories or files are not considered empty.

func (*Config) Debugger

func (c *Config) Debugger(s string)

Debugger prints the string to stdout whenever Config.Debug is true.

func (*Config) Print

func (c *Config) Print() (string, error)

Print the results of a dupe request.

func (*Config) Read

func (c *Config) Read(db *bolt.DB, b parse.Bucket, name, mimeExt string) error

Read opens the named archive, hashes and saves the content to the bucket.

func (*Config) Read7Zip

func (c *Config) Read7Zip(db *bolt.DB, b parse.Bucket, name string) error

Read7Zip opens the named 7-Zip archive, hashes and saves the content to the bucket.

func (*Config) Remove

func (c *Config) Remove() (string, error)

Remove duplicate files from the source directory.

func (*Config) Removes

func (c *Config) Removes() ([]string, error)

Removes the directories from the source that do not contain unique MS-DOS or Windows programs. The strings contains the path of any undeletable files.

func (*Config) StatSource

func (c *Config) StatSource() (isDir bool, files, versus int, err error)

StatSource returns the number of files in the source directory to check. If the source is a file, files will always equal 1. The returned versus the number of items in the buckets for the dupe check.

func (*Config) Status

func (c *Config) Status() string

Status summarizes the file totals and process duration.

func (*Config) WalkArchiver

func (c *Config) WalkArchiver(db *bolt.DB, name parse.Bucket) error

WalkArchiver walks the bucket directory saving the checksums of new files to the database. Any archived files supported by archiver will also have its content hashed. Archives within archives are currently left unwalked.

func (*Config) WalkDir

func (c *Config) WalkDir(db *bolt.DB, name parse.Bucket) error

WalkDir walks the named bucket directory for any new files to add their checksums to the database.

func (*Config) WalkDirs

func (c *Config) WalkDirs(db *bolt.DB) error

WalkDirs walks the named bucket directories for any new files to add their checksums to the database.

func (*Config) WalkSource

func (c *Config) WalkSource() error

WalkSource walks the source directory or a file to collect the hashed content for a future comparison.

func (*Config) Writer

func (c *Config) Writer(w io.Writer, s string)

Writer writes the string to the io.writer whenever Config.Debug is true.

Directories

Path Synopsis
internal
archive
© Ben Garrett https://github.com/bengarrett/dupers
© Ben Garrett https://github.com/bengarrett/dupers
© Ben Garrett https://github.com/bengarrett/dupers
© Ben Garrett https://github.com/bengarrett/dupers

Jump to

Keyboard shortcuts

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