database

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package database interacts with Dupers bbolt database and buckets.

Index

Constants

View Source
const (
	PrivateFile fs.FileMode = 0600
	PrivateDir  fs.FileMode = 0700

	NotFound = "This is okay as one will be created when using the dupe or search commands."
)

Variables

View Source
var (
	ErrBucketNotFound = bolt.ErrBucketNotFound
	ErrBucketAsFile   = errors.New("bucket points to a file, not a directory")
	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")
)

Functions

func Abs

func Abs(bucket string) ([]byte, error)

Abs returns an absolute representation of the named bucket.

func AllBuckets

func AllBuckets(db *bolt.DB) (names []string, err error)

AllBuckets lists all the stored bucket names in the database.

func Backup

func Backup() (name string, written int64, err error)

Backup makes a copy of the database to the named location.

func Clean

func Clean(quiet, debug bool, buckets ...string) error

Clean the stale items from database buckets. Stale items are file pointers that no longer exist on the host file system.

func Compact

func Compact(debug bool) error

Compact the database by reclaiming space.

func CopyFile

func CopyFile(name, dest string) (int64, error)

CopyFile duplicates the named file to the destination filepath.

func Count added in v0.0.8

func Count(b *bolt.Bucket, db *bolt.DB) (int, error)

XXX Count the number of records in the bucket.

func DB

func DB() (string, error)

DB returns the absolute path of the Bolt database.

func Info

func Info() (string, error)

Info returns a printout of the buckets and their statistics.

func IsEmpty

func IsEmpty() (bool, error)

XXX IsEmpty returns true if the database has no buckets.

func OpenRead added in v0.0.9

func OpenRead() (db *bolt.DB, err error)

OpenRead opens the Bolt database for reading.

func OpenWrite added in v0.0.9

func OpenWrite() (db *bolt.DB, err error)

OpenRead opens the Bolt database for writing and reading.

func RM

func RM(name string) error

RM removes the named bucket from the database.

Types

type Bucket

type Bucket string

Bucket is the absolute path to a directory that's used as the bucket name.

type Filepath

type Filepath string

Filepath is the absolute path to a file used as a map key.

type Lists

type Lists map[Filepath][32]byte

Lists are a collection of fetched filepaths and their SHA256 checksums.

func List

func List(bucket string, db *bolt.DB) (ls Lists, err error)

List returns the file paths and SHA256 checksums stored in the bucket.

type Matches

type Matches map[Filepath]Bucket

Matches are a collection of fetched filepaths and the bucket they were sourced from.

func Compare

func Compare(s string, buckets ...string) (*Matches, error)

Compare finds exact matches of the string contained within the stored filenames and paths.

func CompareBase

func CompareBase(s string, buckets ...string) (*Matches, error)

CompareBase finds exact matches of the string contained within the stored filenames.

func CompareBaseNoCase

func CompareBaseNoCase(s string, buckets ...string) (*Matches, error)

CompareBaseNoCase finds case insensitive matches of the string contained within the stored filenames.

func CompareNoCase

func CompareNoCase(s string, buckets ...string) (*Matches, error)

CompareNoCase finds case insensitive matches of the string contained within the stored filenames and paths.

Jump to

Keyboard shortcuts

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