Documentation
¶
Overview ¶
Package database interacts with Dupers bbolt database and buckets.
Index ¶
- Constants
- Variables
- func Abs(name string) (string, error)
- func AbsB(name string) ([]byte, error)
- func All(db *bolt.DB) ([]string, error)
- func Backup() (string, int64, error)
- func CSVExport(db *bolt.DB, bucket string) (string, error)
- func CSVImport(db *bolt.DB, name string, assumeYes bool) (int, error)
- func Check() (int64, error)
- func Clean(db *bolt.DB, quiet, debug bool, buckets ...string) error
- func Compact(db *bolt.DB, debug bool) error
- func CopyFile(name, dest string) (int64, error)
- func Count(db *bolt.DB, name string) (int, error)
- func Create(path string) error
- func DB() (string, error)
- func Exist(db *bolt.DB, bucket string) error
- func Home() (string, error)
- func Import(db *bolt.DB, name Bucket, ls *Lists) (int, error)
- func Info(db *bolt.DB) (string, error)
- func IsEmpty(db *bolt.DB) error
- func OpenRead() (*bolt.DB, error)
- func OpenWrite() (*bolt.DB, error)
- func Remove(db *bolt.DB, name string) error
- func Rename(db *bolt.DB, name, target string) error
- func Usage(db *bolt.DB, name string, assumeYes bool) (string, error)
- type Bucket
- type Filepath
- type Lists
- type Matches
- func Compare(db *bolt.DB, s string, buckets ...string) (*Matches, error)
- func CompareBase(db *bolt.DB, s string, buckets ...string) (*Matches, error)
- func CompareBaseNoCase(db *bolt.DB, s string, buckets ...string) (*Matches, error)
- func CompareNoCase(db *bolt.DB, s string, buckets ...string) (*Matches, error)
Constants ¶
const ( PrivateFile fs.FileMode = 0o600 // PrivateFile mode means only the owner has read/write access. PrivateDir fs.FileMode = 0o700 // PrivateDir mode means only the owner has read/write/dir access. NotFound = "This is okay as one will be created when using the dupe or search commands." )
const (
Timeout = 3 * time.Second // Timeout lock option for the Bolt database.
)
Variables ¶
var ( ErrEmpty = errors.New("database is empty and contains no items") ErrNoCompact = errors.New("compression has not reduced the database size") ErrNoClean = errors.New("database has nothing to clean") ErrNoTerm = errors.New("cannot compare an empty term") ErrNotFound = errors.New("database file does not exist") ErrSameName = errors.New("bucket target is the same as the bucket name") ErrZeroByte = errors.New("database is a zero byte file and is unusable") )
Functions ¶
func Backup ¶
Backup makes a copy of the database to the named location.
Returned is the path to the database and the number of bytes copied.
func CSVExport ¶
CSVExport saves the bucket data to an export csv file. The generated file is RFC 4180 compatible using comma-separated values.
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 ¶
Home returns the user's home directory. Or if that fails, returns the current working directory.
func Import ¶
Import the list of data and save it to the database. If the named bucket does not exist, it is created.
The returned int is the number of records imported.
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bucket provides database bucket management functionality.
|
Package bucket provides database bucket management functionality. |
|
Package csv provides CSV import/export functionality for database operations.
|
Package csv provides CSV import/export functionality for database operations. |