Documentation ¶
Overview ¶
Package catalog provides tools to maintain an index of all medias that have been backed up.
Index ¶
- Variables
- func Create(createRequest CreateAlbum) error
- func DeleteAlbum(folderNameToDelete string, emptyOnly bool) error
- func InsertMedias(medias []CreateMediaRequest) error
- func RelocateMovedMedias(operator MoveMediaOperator, transactionId string) (int, error)
- func RenameAlbum(folderName, newName string, renameFolder bool) error
- func UpdateAlbum(folderName string, start, end time.Time) error
- type Album
- type AlbumStat
- type CreateAlbum
- type CreateMediaRequest
- type FindMediaFilter
- type MediaDetails
- type MediaLocation
- type MediaMeta
- type MediaOrientation
- type MediaPage
- type MediaSignature
- type MediaSignatureAndLocation
- type MediaType
- type MoveMediaOperator
- type MoveTransaction
- type MovedMedia
- type PageRequest
- type PrioritySegment
- type RepositoryPort
- type TimeRange
- type Timeline
- func (t *Timeline) AppendAlbum(album *Album) (*Timeline, error)
- func (t *Timeline) FindAllAt(date time.Time) []*Album
- func (t *Timeline) FindAt(date time.Time) (*Album, bool)
- func (t *Timeline) FindBetween(start, end time.Time) (segments []PrioritySegment, missed []PrioritySegment)
- func (t *Timeline) FindForAlbum(folderName string) (segments []PrioritySegment)
- type UpdateMediaFilter
Constants ¶
This section is empty.
Variables ¶
var ( NotFoundError = errors.New("Album hasn't been found") NotEmptyError = errors.New("Album is not empty") )
Functions ¶
func DeleteAlbum ¶
DeleteAlbum delete an album, medias it contains are dispatched to other albums.
func InsertMedias ¶
func InsertMedias(medias []CreateMediaRequest) error
InsertMedias stores metadata and location of photo and videos
func RelocateMovedMedias ¶
func RelocateMovedMedias(operator MoveMediaOperator, transactionId string) (int, error)
RelocateMovedMedias drives the physical re-location of all medias that have been flagged.
func RenameAlbum ¶
RenameAlbum updates the displayed named of the album. Optionally changes the folder in which media will be stored and flag all its media to be moved to the new one.
Types ¶
type Album ¶
type Album struct { Name string FolderName string // unique and immutable Start time.Time End time.Time }
Album defines how medias are physically stored.
func FindAlbum ¶
FindAlbum get an album by its business key (its folder name), or returns NotFoundError
func FindAllAlbums ¶
FindAllAlbums find all albums owned by root user
type AlbumStat ¶
type AlbumStat struct { Album Album // contains filtered or unexported fields }
AlbumStat has the counts of media on the album ; it's currently limited to total number because of the database.
func FindAllAlbumsWithStats ¶
FindAllAlbumsWithStats returns the list of albums, with statistics for each
func (*AlbumStat) TotalCount ¶
TotalCount return the number of medias, no matter their type, in the album.
type CreateAlbum ¶
func (*CreateAlbum) String ¶
func (c *CreateAlbum) String() string
type CreateMediaRequest ¶
type CreateMediaRequest struct { Location MediaLocation Type MediaType Details MediaDetails Signature MediaSignature }
type FindMediaFilter ¶
type FindMediaFilter struct { PageRequest PageRequest // PageRequest size will use a default if too high or not set (0) TimeRange TimeRange // TimeRange is optional }
FindMediaFilter is a filter that is applied to find medias within a time range.
type MediaDetails ¶
type MediaDetails struct {
Width, Height int
DateTime time.Time
Orientation MediaOrientation
Make string
Model string
GPSLatitude, GPSLongitude float64
Duration int64 // Duration is the length, in milliseconds, of a video
VideoEncoding string // VideoEncoding is the codec used to encode the video (ex: 'H264')
}
type MediaLocation ¶
type MediaMeta ¶
type MediaMeta struct { Signature MediaSignature // Signature is the key used to get the image (or its location) Filename string // Filename original filename when image was uploaded Type MediaType Details MediaDetails }
type MediaOrientation ¶
type MediaOrientation string
type MediaPage ¶
type MediaPage struct { NextPage string // NextPage is empty if no other pages Content []*MediaMeta }
MediaPage is the current page MediaMeta, and the token of the next page
func ListMedias ¶
func ListMedias(folderName string, request PageRequest) (*MediaPage, error)
ListMedias return a page of medias within an album
type MediaSignature ¶
func FindSignatures ¶
func FindSignatures(signatures []*MediaSignature) ([]*MediaSignature, error)
FindSignatures returns a list of the medias already known ; they can't be duplicated
func (MediaSignature) String ¶
func (s MediaSignature) String() string
type MediaSignatureAndLocation ¶
type MediaSignatureAndLocation struct { Location MediaLocation Signature MediaSignature }
type MoveMediaOperator ¶
type MoveMediaOperator interface { // Move must perform the physical move of the file to a different directory ; return the final name if it has been changed Move(source, dest MediaLocation) (string, error) // UpdateStatus informs of the global status of the move operation UpdateStatus(done, total int) error // Continue requests if the operation should continue or be interrupted Continue() bool }
type MoveTransaction ¶
type MoveTransaction struct { TransactionId string Count int // Number of medias to be moved as part of this transaction }
func FindMoveTransactions ¶
func FindMoveTransactions() ([]*MoveTransaction, error)
FindMoveTransactions lists transactions of media requiring to be physically moved.
type MovedMedia ¶
type MovedMedia struct { Signature MediaSignature SourceFolderName string SourceFilename string TargetFolderName string TargetFilename string }
type PageRequest ¶
type PrioritySegment ¶
type RepositoryPort ¶
type RepositoryPort interface { FindAllAlbums() ([]*Album, error) InsertAlbum(album Album) error DeleteEmptyAlbum(folderName string) error // FindAlbum returns (nil, NotFoundError) when not found FindAlbum(folderName string) (*Album, error) // UpdateAlbum updates data of matching Album.FolderName UpdateAlbum(album Album) error // CountMedias counts number of media within the album CountMedias(folderName string) (int, error) // InsertMedias bulks insert medias InsertMedias(media []CreateMediaRequest) error // FindMedias is a paginated search of medias within an album, and optionally within a time range FindMedias(folderName string, filter FindMediaFilter) (*MediaPage, error) // FindExistingSignatures returns the signatures that are already known FindExistingSignatures(signatures []*MediaSignature) ([]*MediaSignature, error) // UpdateMedias updates metadata and mark the media to be moved, the AlbumFolderName is never updated (part of the primary key) UpdateMedias(filter *UpdateMediaFilter, newFolderName string) (string, int, error) FindReadyMoveTransactions() ([]*MoveTransaction, error) FindFilesToMove(transactionId, pageToken string) ([]*MovedMedia, string, error) UpdateMediasLocation(transactionId string, moves []*MovedMedia) error DeleteEmptyMoveTransaction(transactionId string) error }
var (
Repository RepositoryPort
)
type TimeRange ¶
TimeRange is of days, start is inclusive (at the second), end is exclusive (at the second)
type Timeline ¶
type Timeline struct {
// contains filtered or unexported fields
}
Timeline can be used to find to which album a media will belongs.
func NewTimeline ¶
NewTimeline creates a Timeline object used to compute overlaps between Album. List of albums must be sorted by Start date ASC (End sorting do not matter).
func (*Timeline) AppendAlbum ¶
AppendAlbum generates a new timeline from memory
func (*Timeline) FindBetween ¶
func (t *Timeline) FindBetween(start, end time.Time) (segments []PrioritySegment, missed []PrioritySegment)
func (*Timeline) FindForAlbum ¶
func (t *Timeline) FindForAlbum(folderName string) (segments []PrioritySegment)
type UpdateMediaFilter ¶
type UpdateMediaFilter struct { AlbumFolderNames map[string]interface{} // AlbumFolderNames is a set of folder names (map value is nil) Ranges []TimeRange // empty = no restriction }
UpdateMediaFilter is used internally to update a range of folders
func NewUpdateFilter ¶
func NewUpdateFilter() *UpdateMediaFilter
func (*UpdateMediaFilter) String ¶
func (m *UpdateMediaFilter) String() string
func (*UpdateMediaFilter) WithAlbum ¶
func (m *UpdateMediaFilter) WithAlbum(folderNames ...string) *UpdateMediaFilter
func (*UpdateMediaFilter) WithinRange ¶
func (m *UpdateMediaFilter) WithinRange(start, end time.Time) *UpdateMediaFilter
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
dynamo
Package dynamodb package store all the data in a single multi-tenant table: - OWNER > Album X meta > Album Y meta - MEDIA (OWNER#SIGNATURE) > #META > LOCATION > MOVE LOCATION > MOVE LOCATION - MOVE TRANSACTION (...#uniqueID)
|
Package dynamodb package store all the data in a single multi-tenant table: - OWNER > Album X meta > Album Y meta - MEDIA (OWNER#SIGNATURE) > #META > LOCATION > MOVE LOCATION > MOVE LOCATION - MOVE TRANSACTION (...#uniqueID) |