Documentation ¶
Index ¶
- func Close(db *sql.DB) error
- func CountFiles(db *sql.DB) (int, error)
- func HasAlternative(db *sql.DB, f File) (bool, error)
- func InitDuplicate(db *sql.DB) error
- func InsertDuplicate(db *sql.DB, f File, checksum string) error
- func ListDuplicateFiles(ctx context.Context, db *sql.DB) (chan DuplicateFile, chan error)
- func ListFiles(ctx context.Context, db *sql.DB) (chan File, chan error)
- func NewInsertDuplicateHandler(duplicateDB *sql.DB, errorLog io.Writer, ...) func(f File, counter Counter) error
- func NewSynchronizeSidecarsHandler(db *sql.DB) func(f File, counter Counter) error
- func Open(path string) (*sql.DB, error)
- func OpenDuplicate(path string) (*sql.DB, error)
- func ProcessAllDuplicateFiles(db *sql.DB, handler func(DuplicateFile, Counter) error, counter Counter) error
- func UpdateSidecarExtensions(db *sql.DB, f File, extensions []string) (bool, error)
- func WalkFiles(db *sql.DB, handler func(File, Counter) error, counter Counter) error
- type Counter
- type DuplicateFile
- type Error
- type File
- type FileRef
- type FileRefSlice
- type NopCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
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 ¶
CountFiles returns the number of files referenced in a lightroom catalog
func HasAlternative ¶
HasAlternative checks whether there exists another file with the same name but another extension in the same folder in the lightroom catalog
func InitDuplicate ¶
InitDuplicate initializes a duplicates database, if the tables already exist, they are deleted and re-created.
func InsertDuplicate ¶
InsertDuplicate inserts the lightroom file in the duplicates database.
func ListDuplicateFiles ¶
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 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 ¶
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 ¶
Open creates a new connection to a lightroom catalog.
The database is opened read/write for update purposes.
func OpenDuplicate ¶
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 ¶
UpdateSidecarExtensions updates the lightroom catalog wiith the new extension list if needed
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 ¶
Error tracking an error without loosing track of the parent error, and types
func SynchronizeSidecars ¶
SynchronizeSidecars detects the existing sidecars on disk and ensures the lightroom catalog is up to date with those.
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 (*File) FindSidecarsExtensions ¶
FindSidecarsExtensions returns the list of all extensions a file from disk
type FileRefSlice ¶
type FileRefSlice []FileRef
FileRefSlice implements basic functions to allow sorting a slice of FileRefs
type NopCounter ¶
type NopCounter struct{}
NopCounter implements the Counter interface with no tracked action