Documentation
¶
Overview ¶
Package database interacts with Dupers bbolt database and buckets.
© Ben Garrett https://github.com/bengarrett/dupers
Index ¶
- Constants
- Variables
- func Abs(name string) (string, error)
- func AbsB(name string) ([]byte, error)
- func All(db *bolt.DB) (names []string, err error)
- func Backup() (name string, written int64, err error)
- func CSVExport(bucket string, db *bolt.DB) (string, error)
- func CSVImport(name string, db *bolt.DB) (records int, err error)
- func Check() error
- func Clean(quiet, debug bool, buckets ...string) error
- func Compact(debug bool) error
- func CopyFile(name, dest string) (int64, error)
- func Count(name string, db *bolt.DB) (items int, err error)
- func Create(path string) error
- func DB() (string, error)
- func Exist(bucket string, db *bolt.DB) error
- func Home() (string, error)
- func Import(name Bucket, ls *Lists, db *bolt.DB) (imported int, err error)
- func Info() (string, error)
- func IsEmpty() (bool, error)
- func OpenRead() (db *bolt.DB, err error)
- func OpenWrite() (db *bolt.DB, err error)
- func RM(name string) error
- func Rename(name, newName string) error
- func Usage(name string, db *bolt.DB) (string, error)
- type Bucket
- type Filepath
- type Lists
- type Matches
Constants ¶
Variables ¶
var ( ErrBucketNotFound = bolt.ErrBucketNotFound ErrDBClean = errors.New("database has nothing to clean") ErrDBCompact = errors.New("database compression has not reduced the size") ErrDBEmpty = errors.New("database is empty and contains no items") ErrDBNotFound = errors.New("database file does not exist") ErrDBZeroByte = errors.New("database is a zero byte file") TestMode = false // nolint: gochecknoglobals )
var ErrImportList = errors.New("import list is empty")
Functions ¶
func CSVExport ¶ added in v1.0.1
CSVExport saves the bucket data to an export csv file. The generated file is RFC 4180 compatible using comma-separated values.
func CSVImport ¶ added in v1.0.1
CSVImport reads the named csv export file and imports its content to the database.
func Clean ¶
Clean the stale items from database buckets. Stale items are file pointers that no longer exist on the host file system.
func Home ¶ added in v0.1.0
Home returns the user's home directory. Or if that fails, returns the current working directory.
func Import ¶ added in v0.1.0
Import the list of data and save it to the database. If the named bucket does not exist, it is created.
Types ¶
type Bucket ¶
type Bucket string
Bucket is the absolute path to the directory that is used as the bucket name.
type Lists ¶
Lists are a collection of fetched filepaths and their SHA256 checksums.
type Matches ¶
Matches are a collection of fetched filepaths and the bucket they were sourced from.
func Compare ¶
Compare finds exact matches of the string contained within the stored filenames and paths.
func CompareBase ¶
CompareBase finds exact matches of the string contained within the stored filenames.
func CompareBaseNoCase ¶
CompareBaseNoCase finds case insensitive matches of the string contained within the stored filenames.