database

package
v0.0.0-...-a5018ba Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Folder string
	DB     *sql.DB
	Config config.Config
}

DB 数据库

func (*DB) AddBackupBucket

func (db *DB) AddBackupBucket(bucket string) error

func (*DB) AddTagGroup

func (db *DB) AddTagGroup(group *TagGroup) error

func (*DB) AllFiles

func (db *DB) AllFiles() (files []*File, err error)

func (*DB) AllFilesWithoutTags

func (db *DB) AllFilesWithoutTags() ([]*File, error)

func (*DB) AllImages

func (db *DB) AllImages() (files []*File, err error)

func (*DB) CheckBeforeDeleteTag

func (db *DB) CheckBeforeDeleteTag(tagName string) error

func (*DB) CheckFilesHash

func (db *DB) CheckFilesHash(bucket string) error

CheckFilesHash 只校验长时间未校验的文件,忽略短期内曾校验过的文件。 每次只校验有限的文件,避免校验耗时太长。

func (*DB) Close

func (db *DB) Close() error

func (*DB) CurrentFileID

func (db *DB) CurrentFileID() (string, error)

func (*DB) DamagedFileIDs

func (db *DB) DamagedFileIDs() ([]string, error)

func (*DB) DamagedFiles

func (db *DB) DamagedFiles() ([]*File, error)

func (*DB) DeleteBackupBucket

func (db *DB) DeleteBackupBucket(i int) error

func (*DB) DeleteFile

func (db *DB) DeleteFile(id string) error

func (*DB) DeletedFiles

func (db *DB) DeletedFiles() (files []*File, err error)

func (*DB) Exec

func (db *DB) Exec(query string, args ...interface{}) (err error)

func (*DB) FileHash

func (db *DB) FileHash(id string) (string, error)

func (*DB) ForceCheckFilesHash

func (db *DB) ForceCheckFilesHash(bucket string) error

ForceCheckFilesHash 不检查上次校验日期,强制校验全部文件。

func (*DB) GetAllTags

func (db *DB) GetAllTags(query string) (tags []Tag, err error)

func (*DB) GetBackupBuckets

func (db *DB) GetBackupBuckets() ([]string, error)

func (*DB) GetBackupFolder

func (db *DB) GetBackupFolder(i int) (string, error)

func (*DB) GetFileID

func (db *DB) GetFileID(hash string) (id string, ok bool)

func (*DB) GetFileIDsByName

func (db *DB) GetFileIDsByName(name string) ([]string, error)

func (*DB) GetFileName

func (db *DB) GetFileName(id string) (string, error)

func (*DB) GetGroupsByTag

func (db *DB) GetGroupsByTag(name string) (groups [][]string, err error)

func (*DB) GetInfo

func (db *DB) GetInfo() (Info, error)

func (*DB) GetNextFileID

func (db *DB) GetNextFileID() string

func (*DB) GetTagsByFile

func (db *DB) GetTagsByFile(id string) ([]string, error)

func (*DB) InsertFiles

func (db *DB) InsertFiles(files []*File) error

func (*DB) IsFileExist

func (db *DB) IsFileExist(id string) bool

func (*DB) IsTagExist

func (db *DB) IsTagExist(name string) (bool, error)

func (*DB) NewFile

func (db *DB) NewFile() *File

func (*DB) Open

func (db *DB) Open(dbPath string, cfg config.Config) (err error)

func (*DB) OpenBackup

func (db *DB) OpenBackup(dbPath string, cfg config.Config) (err error)

OpenBackup opens a backup database.

func (*DB) RecheckFile

func (db *DB) RecheckFile(folder string, file *File) (damaged bool, err error)

注意这里的 folder 与 db 匹配, db 与 file 必须分别属于不同的仓库,进行对比。 即,如果 db 是主仓库,则 file 应属于备份仓库; 如果 db 是备份仓库,则 file 应属于主仓库。

func (*DB) RenameFiles

func (db *DB) RenameFiles(id, name string) error

RenameFiles 统一修改全部同名文件的文件名。

func (*DB) RenameTag

func (db *DB) RenameTag(oldName, newName string) error

func (*DB) ReplaceFile

func (db *DB) ReplaceFile(file *File) error

func (*DB) SearchDamagedFiles

func (db *DB) SearchDamagedFiles() ([]*File, error)

func (*DB) SearchFileName

func (db *DB) SearchFileName(pattern string, fileType string) (files []*File, err error)

func (*DB) SearchSameNameFiles

func (db *DB) SearchSameNameFiles(id string) ([]*File, error)

func (*DB) SearchTags

func (db *DB) SearchTags(tags []string, fileType string) ([]*File, error)

func (*DB) TagGroups

func (db *DB) TagGroups() (groups []TagGroup, err error)

func (*DB) TotalSize

func (db *DB) TotalSize() (int64, error)

TotalSize 返回数据库的总体积,单位是 KB.

func (*DB) UpdateLastBackupNow

func (db *DB) UpdateLastBackupNow() error

func (*DB) UpdateTags

func (db *DB) UpdateTags(fileID string, tags []string) error

type File

type File = model.File

type Info

type Info struct {
	BucketLocation    string
	LastChecked       int64
	LastBackup        int64
	AllFilesCount     int64
	DamagedFilesCount int64
	FilesWaitingCheck int64
	TotalSize         int64
}

Info of the database

type Row

type Row interface {
	Scan(...interface{}) error
}

type Set

type Set = stringset.Set

type ShortID

type ShortID = model.ShortID

type Stmt

type Stmt = sql.Stmt

type TX

type TX interface {
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
	Prepare(string) (*Stmt, error)
}

type Tag

type Tag = model.Tag

type TagGroup

type TagGroup = model.TagGroup

Jump to

Keyboard shortcuts

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