lightroom

package module
v0.0.0-...-40ab792 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db *sql.DB) error

Close cleanly closes the connection to a catalog.

It is recommended to be called in a defer right after a connection is created: ```

db, err := lightroom.Open("path-to.lrcat")
if err != nil {
	// do something
}
defer lightroom.Close(db)

```

func CountFiles

func CountFiles(db *sql.DB) (int, error)

CountFiles returns the number of files referenced in a lightroom catalog

func HasAlternative

func HasAlternative(db *sql.DB, f File) (bool, error)

HasAlternative checks whether there exists another file with the same name but another extension in the same folder in the lightroom catalog

func InitDuplicate

func InitDuplicate(db *sql.DB) error

InitDuplicate initializes a duplicates database, if the tables already exist, they are deleted and re-created.

func InsertDuplicate

func InsertDuplicate(db *sql.DB, f File, checksum string) error

InsertDuplicate inserts the lightroom file in the duplicates database.

func ListDuplicateFiles

func ListDuplicateFiles(ctx context.Context, db *sql.DB) (chan DuplicateFile, chan error)

ListDuplicateFiles iterates over all files in the duplicates table.

Duplication is detected using the file checksum Files returned may contain only one file reference, in such a case, the file is not duplicated.

func ListFiles

func ListFiles(ctx context.Context, db *sql.DB) (chan File, chan error)

ListFiles allows to iterate over all known files in a lightroom catalog

func NewInsertDuplicateHandler

func NewInsertDuplicateHandler(duplicateDB *sql.DB, errorLog io.Writer, checksum func(path string) (string, error)) func(f File, counter Counter) error

NewInsertDuplicateHandler allows to walk through all fiiles in the lightroom library and insert its checksum as duplicates in a duplicates database.

func NewSynchronizeSidecarsHandler

func NewSynchronizeSidecarsHandler(db *sql.DB) func(f File, counter Counter) error

NewSynchronizeSidecarsHandler returns a handler to be used together with the file walker to synchronize all sidecar of known files in the lightroom catalog

func Open

func Open(path string) (*sql.DB, error)

Open creates a new connection to a lightroom catalog.

The database is opened read/write for update purposes.

func OpenDuplicate

func OpenDuplicate(path string) (*sql.DB, error)

OpenDuplicate creates a new connection to a duplicates database.

The database leaves as a sidecar of the main lightroom library. If the database does not exist, it will be created with no schema.

func ProcessAllDuplicateFiles

func ProcessAllDuplicateFiles(db *sql.DB, handler func(DuplicateFile, Counter) error, counter Counter) error

ProcessAllDuplicateFiles walks through all references in the duplicates database, calling one handler per checksum

func UpdateSidecarExtensions

func UpdateSidecarExtensions(db *sql.DB, f File, extensions []string) (bool, error)

UpdateSidecarExtensions updates the lightroom catalog wiith the new extension list if needed

func WalkFiles

func WalkFiles(db *sql.DB, handler func(File, Counter) error, counter Counter) error

WalkFiles is a helper to iterates over all known files in the lightroom catalog

Types

type Counter

type Counter interface {
	Inc(metric string)
}

Counter allows to count items for processors to report progress

type DuplicateFile

type DuplicateFile struct {
	FileRef  FileRefSlice
	Checksum string
}

DuplicateFile holds all detected duplicates of a file, grouped by checksum

type Error

type Error struct {
	Type        string
	Message     string
	ParentError error
}

Error tracking an error without loosing track of the parent error, and types

func SynchronizeSidecars

func SynchronizeSidecars(db *sql.DB, f File) *Error

SynchronizeSidecars detects the existing sidecars on disk and ensures the lightroom catalog is up to date with those.

func (Error) Error

func (e Error) Error() string

type File

type File struct {
	// AbsolutePath holds the path of the root directory in lightroom. It is, from observations, either absolute or relative from the directory the catalog lives in.
	AbsolutePath      string
	PathFromRoot      string
	Filename          string
	Basename          string
	SidecarExtensions []string
	RootFolderID      int
	FolderID          int
	FileID            int
}

File holds the data gathered from Lightroom database about a given library file.

A File can be either a picture or a video.

func FindFile

func FindFile(db *sql.DB, fileID int) (File, error)

FindFile retrieves a File details from a lightroom catalog, given its ID

func (*File) FindSidecarsExtensions

func (f *File) FindSidecarsExtensions() ([]string, error)

FindSidecarsExtensions returns the list of all extensions a file from disk

func (*File) Path

func (f *File) Path() string

Path returns the full path of a given file on the file system.

In case the path is relative, it is, from observations, provided relative from the directory the catalog lives in.

type FileRef

type FileRef struct {
	FileID int
	Path   string
}

FileRef holds both the 'absolute' path and the lightroom FileID for a given file.

type FileRefSlice

type FileRefSlice []FileRef

FileRefSlice implements basic functions to allow sorting a slice of FileRefs

func (FileRefSlice) Len

func (s FileRefSlice) Len() int

Len ...

func (FileRefSlice) Swap

func (s FileRefSlice) Swap(i, j int)

Swap ...

type NopCounter

type NopCounter struct{}

NopCounter implements the Counter interface with no tracked action

func (NopCounter) Inc

func (NopCounter) Inc(string)

Inc does nothing as a dummy Counter

Jump to

Keyboard shortcuts

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