database

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package database interacts with Dupers bbolt database and buckets.

Index

Constants

View Source
const (
	FileMode fs.FileMode = 0600
)

Variables

View Source
var (
	ErrNoBucket  = errors.New("bucket does not exist")
	ErrDB        = errors.New("database does not exist")
	ErrDBClean   = errors.New("database had nothing to clean")
	ErrDBCompact = errors.New("database compression has not reduced the size")
)

Functions

func Abs added in v0.0.4

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

Abs returns an absolute representation of the named bucket.

func AllBuckets added in v0.0.4

func AllBuckets() (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) error

Clean the stale items from all 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 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)

IsEmpty returns true if the database has no buckets.

func RM

func RM(name string) error

RM removes the named bucket from the database.

func Seek

func Seek(sum [32]byte, bucket string) (finds []string, records int, err error)

Seek searches a bucket for an exact SHA256 checksum match.

Types

type Bucket added in v0.0.4

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 added in v0.0.4

type Lists map[Filepath][32]byte

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

func List added in v0.0.4

func List(bucket string) (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