database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	*File
	Duration *time.Duration
	Author   string
	Year     *int
}

type AudioFilter

type AudioFilter struct {
	FileFilter
	MinDuration, MaxDuration *time.Duration
	Author                   string
	MinYear, MaxYear         *int
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB represents a database connection. It is not safe for asynchronous write accesses. Use the BeginTx, Commit, Rollback and Add* Methods in series only.

func NewDB

func NewDB(dbFile string) (DB, error)

NewDB creates a new database by initializing or updating the schema and returns the ready to use database.

func (DB) AddAudio

func (db DB) AddAudio(audio *Audio) error

AddAudio adds an audio file to the database. If the audio already exists, nothing will be done. db.BeginTx must have been called before.

func (DB) AddDocument

func (db DB) AddDocument(doc *Document) error

AddDocument adds a document to the database. If the document already exists, nothing will be done. db.BeginTx must have been called before.

func (DB) AddFile

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

AddFile adds an unspecific file to the database. If the file already exists, nothing will be done. db.BeginTx must have been called before.

func (DB) AddPicture

func (db DB) AddPicture(pic *Picture) error

AddPicture adds a picture to the database. If the picture already exists, nothing will be done. db.BeginTx must have been called before.

func (DB) AddVideo

func (db DB) AddVideo(vid *Video) error

AddVideo adds a picture to the database. If the video already exists, nothing will be done. db.BeginTx must have been called before.

func (DB) AllFileCount

func (db DB) AllFileCount() (int, error)

func (DB) AllFileInfosAt

func (db DB) AllFileInfosAt(path string) (map[string]ShortFileInfo, error)

AllFileInfosAt returns a map with paths as keys, containing all stored paths below the given path with file info.

db.Begin must have been called to create a transaction before calling AllFileInfosAt.

func (*DB) BeginTx

func (db *DB) BeginTx() error

BeginTx starts a transaction. It must be called before writing to the database. If a transaction is already in progress, BeginTx will block until a transaction can be started.

Do not use when just reading from the database.

It is the callers responsibility to call db.Commit or db.Rollback the end the transaction.

func (*DB) Commit

func (db *DB) Commit() error

func (DB) DeletePaths

func (db DB) DeletePaths(paths []string) error

DeletePaths deletes all file entries for the given paths.

db.Begin must have been called to create a transaction before calling DeletePaths.

func (DB) PrintAllDetails

func (db DB) PrintAllDetails() error

func (DB) PrintAllPaths

func (db DB) PrintAllPaths(filter FileFilter) error

func (DB) PrintAudiosDetails

func (db DB) PrintAudiosDetails() error

func (DB) PrintAudiosPaths

func (db DB) PrintAudiosPaths(filter AudioFilter) error

func (DB) PrintDocumentsDetails

func (db DB) PrintDocumentsDetails() error

func (DB) PrintDocumentsPaths

func (db DB) PrintDocumentsPaths(filter DocumentFilter) error

func (DB) PrintOthersDetails

func (db DB) PrintOthersDetails() error

func (DB) PrintOthersPaths

func (db DB) PrintOthersPaths(filter FileFilter) error

func (DB) PrintPicturesDetails

func (db DB) PrintPicturesDetails() error

func (DB) PrintPicturesPaths

func (db DB) PrintPicturesPaths(filter PictureFilter) error

func (DB) PrintVideosDetails

func (db DB) PrintVideosDetails() error

func (DB) PrintVideosPaths

func (db DB) PrintVideosPaths(filter VideoFilter) error

func (*DB) Rollback

func (db *DB) Rollback() error

func (*DB) TrackPath

func (db *DB) TrackPath(path string) error

TrackPath adds a path to be tracked. It will return an error if the path is already tracked.

func (*DB) TrackedPaths

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

TrackedPaths returns a list of all tracked paths.

func (*DB) UntrackPath

func (db *DB) UntrackPath(path string) error

UntrackPath removes the given path from the tracked paths. It also removes all file entries that existed only because of this path.

type Document

type Document struct{ *File }

type DocumentFilter

type DocumentFilter struct {
	FileFilter
	TxtOnly bool
}

type File

type File struct {
	Path         string
	Size         int64
	CreatedGuess time.Time
	Modified     time.Time
	MIME         string
	// contains filtered or unexported fields
}

type FileFilter

type FileFilter struct {
	CreatedSince, CreatedUntil *time.Time
	Prefix                     string
}

type Picture

type Picture struct {
	*File
	Camera string
}

type PictureFilter

type PictureFilter struct {
	FileFilter
	Camera string
}

type ShortFileInfo

type ShortFileInfo struct {
	Size    int64
	ModTime time.Time
}

type Video

type Video struct {
	*File
	Duration *time.Duration
	Camera   string
	Year     *int
}

type VideoFilter

type VideoFilter struct {
	FileFilter
	MinDuration, MaxDuration *time.Duration
	Camera                   string
	MinYear, MaxYear         *int
}

Jump to

Keyboard shortcuts

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