Documentation
¶
Overview ¶
Package database interacts with Dupers bbolt database and buckets.
Package database interacts with Dupers bbolt database and buckets.
Index ¶
- Constants
- Variables
- func Abs(bucket string) (string, error)
- func AbsB(bucket string) ([]byte, error)
- func AllBuckets(db *bolt.DB) (names []string, err error)
- func Backup() (name string, written int64, err 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 DB() (string, error)
- func Exist(bucket string, db *bolt.DB) error
- func ExportCSV(bucket string, db *bolt.DB) (name string, err error)
- func Home() (string, error)
- func Import(name Bucket, ls *Lists, db *bolt.DB) (imported int, err error)
- func ImportCSV(name string, db *bolt.DB) (records 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
- type Bucket
- type Filepath
- type Lists
- type Matches
Constants ¶
Variables ¶
var ( ErrBucketNotFound = bolt.ErrBucketNotFound ErrBucketAsFile = errors.New("bucket points to a file, not a directory") ErrBucketSkip = errors.New("bucket directory does not exist") 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") ErrImportFile = errors.New("not a valid dupers export file") )
var ( ErrBucketExists = errors.New("bucket already exists in the database") ErrBucketNotDir = errors.New("bucket path is not a directory") ErrBucketPath = errors.New("directory used by the bucket does not exist on your system") ErrChecksumLen = errors.New("hexadecimal value is invalid") ErrFileNoDesc = errors.New("no file descriptor") ErrImportList = errors.New("import list is empty") ErrImportSyntax = errors.New("import item has incorrect syntax") ErrImportPath = errors.New("import item has an invalid file path") )
Functions ¶
func AllBuckets ¶
AllBuckets lists all the stored bucket names in 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 ExportCSV ¶ added in v0.1.0
ExportCSV saves the bucket data to an export csv file. The generated file is RFC 4180 compatible using comma-separated values.
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.
func ImportCSV ¶ added in v0.1.0
ImportCSV reads the named export csv file and imports its content to the database.
Types ¶
type Bucket ¶
type Bucket string
Bucket is the absolute path to a directory that's used as the bucket name.
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.