Documentation
¶
Overview ¶
Package backup is providing commands to inspect a file system (hard-drive, USB, Android, S3) and backup medias to a remote DPhoto storage.
Index ¶
- Constants
- Variables
- func ClearDetailsReader()
- func Init(archive BArchiveAdapter, refFactory CataloguerFactory, ...)
- func RegisterDetailsReader(reader DetailsReaderAdapter)
- type AlbumLookupPort
- type AlbumReport
- func (c *AlbumReport) GetMediaIndex(mediaType MediaType) int
- func (c *AlbumReport) IncrementCounter(counter *[numberOfMediaType]int, mediaType MediaType, delta int)
- func (c *AlbumReport) IncrementFoundCounter(mediaType MediaType, count int, size int) *AlbumReport
- func (c *AlbumReport) OfType(mediaType MediaType) MediaCounter
- func (c *AlbumReport) Total() MediaCounter
- type AnalysedMedia
- type AnalysedMediaObserver
- type AnalysedMediaObserverFunc
- type Analyser
- type AnalyserDecorator
- type AnalyserDecoratorObserver
- type AnalyserInterrupterObserver
- type AnalyserObserver
- type BArchiveAdapter
- type BackingUpMediaRequest
- type BatchScanner
- type CatalogAdapter
- type CatalogMediaRequest
- type CatalogReference
- type CatalogReferencerObserver
- type CatalogReferencerObserverFunc
- type Cataloguer
- type CataloguerFactory
- type CataloguerFilter
- type CataloguerFilterObserver
- type CataloguerObserver
- type CataloguerWithFilters
- type ChannelPublisher
- func (a *ChannelPublisher) AnalysedMediaChannelCloser()
- func (a *ChannelPublisher) CataloguedChannelCloser()
- func (a *ChannelPublisher) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
- func (a *ChannelPublisher) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
- func (a *ChannelPublisher) WaitToFinish() []error
- type ClosableFoundMedia
- type CompletionReport
- type CompositeRunnerObserver
- func (c *CompositeRunnerObserver) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
- func (c *CompositeRunnerObserver) OnFilteredOut(ctx context.Context, media AnalysedMedia, reference CatalogReference, ...) error
- func (c *CompositeRunnerObserver) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
- func (c *CompositeRunnerObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
- type ConcurrencyParameters
- type CopyRejectsObserver
- type CoreAnalyser
- type DefaultInterrupterObserver
- type DetailsReaderAdapter
- type DetailsReaderOptions
- type ExtraCounts
- type FoundMedia
- type FullMediaSignature
- type IErrorCollectorObserver
- type ImageOrientation
- type InMemoryMedia
- type InsertMediaPort
- type Interrupter
- type MediaCounter
- type MediaDetails
- type MediaPath
- type MediaType
- type NopeAnalyserDecorator
- type Options
- func OptionOnlyAlbums(albums ...string) Options
- func OptionWithListener(listener interface{}) Options
- func OptionWithRejectDir(rejectDir string) Options
- func OptionsBatchSize(batchSize int) Options
- func OptionsConcurrentAnalyserRoutines(concurrent int) Options
- func OptionsConcurrentCataloguerRoutines(concurrent int) Options
- func OptionsConcurrentUploaderRoutines(concurrent int) Options
- func OptionsSkipRejects(skip bool) Options
- func ReduceOptions(requestedOptions ...Options) Options
- type PostAnalyseFilter
- type ProgressObserver
- func (p *ProgressObserver) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
- func (p *ProgressObserver) OnDecoratedAnalyser(ctx context.Context, found FoundMedia, cacheHit bool) error
- func (p *ProgressObserver) OnDuplicatedBackupMediaRequest(ctx context.Context, request []BackingUpMediaRequest) error
- func (p *ProgressObserver) OnFilteredOut(ctx context.Context, media AnalysedMedia, reference CatalogReference, ...) error
- func (p *ProgressObserver) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
- func (p *ProgressObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
- func (p *ProgressObserver) OnUniqueBackupMediaRequest(ctx context.Context, request []BackingUpMediaRequest) error
- type RejectedMediaObserver
- type RunnerUploader
- type RunnerUploaderFunc
- type ScannedFolder
- type SourceVolume
- type TimelineAdapter
- type TrackAnalysed
- type TrackEvents
- type TrackScanComplete
- type TrackUploaded
- type Tracker
- type Uploader
Constants ¶
const ( MediaTypeImage MediaType = "IMAGE" MediaTypeVideo MediaType = "VIDEO" MediaTypeOther MediaType = "OTHER" OrientationUpperLeft ImageOrientation = "UPPER_LEFT" OrientationLowerRight ImageOrientation = "LOWER_RIGHT" OrientationUpperRight ImageOrientation = "UPPER_RIGHT" OrientationLowerLeft ImageOrientation = "LOWER_LEFT" )
const ( ProgressEventAnalysed trackEvent = "analysed" // ProgressEventAnalysed is not useful for progress, it will be fined grained before upload ProgressEventCatalogued trackEvent = "catalogued-v1" // ProgressEventCatalogued is not useful for progress, it will be fined grained before upload )
Variables ¶
var ( ErrAnalyserNoDateTime = errors.New("media must have a date time included in the metadata") ErrCatalogerFilterMustBeInAlbum = errors.New("media must be in album") ErrCatalogerFilterMustNotAlreadyExists = errors.New("media must not already exists") ErrMediaMustNotBeDuplicated = errors.New("media is present twice in the volume") )
var (
MediaCounterZero = MediaCounter{}
)
var SupportedExtensions = map[string]MediaType{ "jpg": MediaTypeImage, "jpeg": MediaTypeImage, "png": MediaTypeImage, "gif": MediaTypeImage, "webp": MediaTypeImage, "raw": MediaTypeImage, "svg": MediaTypeImage, "eps": MediaTypeImage, "mkv": MediaTypeVideo, "mts": MediaTypeVideo, "avi": MediaTypeVideo, "mp4": MediaTypeVideo, "mpeg": MediaTypeVideo, "mov": MediaTypeVideo, "wmv": MediaTypeVideo, "webm": MediaTypeVideo, }
SupportedExtensions is used by SourceVolume adapters to filter files they find
Functions ¶
func ClearDetailsReader ¶ added in v1.5.57
func ClearDetailsReader()
ClearDetailsReader remove all details reader from the default Analyser
func Init ¶
func Init(archive BArchiveAdapter, refFactory CataloguerFactory, insertMedia InsertMediaPort)
Init for scan or backup (but only refFactory is required for scan)
func RegisterDetailsReader ¶
func RegisterDetailsReader(reader DetailsReaderAdapter)
RegisterDetailsReader adds a details reader implementation to the default Analyser
Types ¶
type AlbumLookupPort ¶ added in v1.5.54
type AlbumReport ¶ added in v1.6.35
type AlbumReport struct { New bool // New is true if the album have been created during the backup // contains filtered or unexported fields }
func NewTypeCounter ¶
func NewTypeCounter(mediaType MediaType, count int, size int, isNew bool) *AlbumReport
NewTypeCounter is a convenience method for testing or mocking 'backup' domain
func (*AlbumReport) GetMediaIndex ¶ added in v1.6.35
func (c *AlbumReport) GetMediaIndex(mediaType MediaType) int
func (*AlbumReport) IncrementCounter ¶ added in v1.6.35
func (c *AlbumReport) IncrementCounter(counter *[numberOfMediaType]int, mediaType MediaType, delta int)
func (*AlbumReport) IncrementFoundCounter ¶ added in v1.6.35
func (c *AlbumReport) IncrementFoundCounter(mediaType MediaType, count int, size int) *AlbumReport
func (*AlbumReport) OfType ¶ added in v1.6.35
func (c *AlbumReport) OfType(mediaType MediaType) MediaCounter
func (*AlbumReport) Total ¶ added in v1.6.35
func (c *AlbumReport) Total() MediaCounter
type AnalysedMedia ¶
type AnalysedMedia struct { FoundMedia FoundMedia // FoundMedia is the reference of the file, implementation depends on the VolumeType Type MediaType // Type is 'photo' or 'video' Sha256Hash string // Sha256Hash sha256 of the file Details *MediaDetails // Details are data found within the file (location, date, ...) }
AnalysedMedia is a FoundMedia to which has been attached its type (photo / video) and other details usually found within the file.
type AnalysedMediaObserver ¶ added in v1.6.26
type AnalysedMediaObserver interface {
OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
}
type AnalysedMediaObserverFunc ¶ added in v1.6.35
type AnalysedMediaObserverFunc func(ctx context.Context, media *AnalysedMedia) error
func (AnalysedMediaObserverFunc) OnAnalysedMedia ¶ added in v1.6.35
func (a AnalysedMediaObserverFunc) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
type Analyser ¶ added in v1.6.26
type Analyser interface {
Analyse(ctx context.Context, found FoundMedia, analysedMediaObserver AnalysedMediaObserver, rejectsObserver RejectedMediaObserver) error
}
type AnalyserDecorator ¶ added in v1.5.0
type AnalyserDecorator interface {
Decorate(analyseFunc Analyser, observers ...AnalyserDecoratorObserver) Analyser
}
type AnalyserDecoratorObserver ¶ added in v1.6.26
type AnalyserDecoratorObserver interface {
OnDecoratedAnalyser(ctx context.Context, found FoundMedia, cacheHit bool) error
}
type AnalyserInterrupterObserver ¶ added in v1.6.26
type AnalyserInterrupterObserver struct {
*DefaultInterrupterObserver
}
AnalyserInterrupterObserver interrupts everything, including when the analyser rejected a media.
func (*AnalyserInterrupterObserver) OnRejectedMedia ¶ added in v1.6.26
func (c *AnalyserInterrupterObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
type AnalyserObserver ¶ added in v1.6.35
type AnalyserObserver interface { AnalysedMediaObserver RejectedMediaObserver }
type BArchiveAdapter ¶
type BArchiveAdapter interface { // ArchiveMedia uploads the file in the right folder but might change the name to avoid clash with other existing files. Use files name is always returned. ArchiveMedia(owner string, media *BackingUpMediaRequest) (string, error) }
type BackingUpMediaRequest ¶
type BackingUpMediaRequest struct { AnalysedMedia *AnalysedMedia CatalogReference CatalogReference }
BackingUpMediaRequest is the requests that must be executed to back up the media
type BatchScanner ¶ added in v1.6.35
type BatchScanner struct { }
func (*BatchScanner) Scan ¶ added in v1.6.35
func (s *BatchScanner) Scan(ctx context.Context, owner ownermodel.Owner, volume SourceVolume, optionSlice ...Options) ([]*ScannedFolder, error)
type CatalogAdapter ¶
type CatalogAdapter interface { // IndexMedias add to the catalog following medias IndexMedias(owner string, requests []*CatalogMediaRequest) error }
type CatalogMediaRequest ¶
type CatalogMediaRequest struct { BackingUpMediaRequest *BackingUpMediaRequest ArchiveFilename string // ArchiveFilename is a normalised named generated and used in archive. }
CatalogMediaRequest is the request passed to Archive domain
type CatalogReference ¶ added in v1.5.54
type CatalogReference interface { // Exists returns true if the media exists in the catalog Exists() bool // AlbumCreated returns true if the album was created during the cataloger process AlbumCreated() bool // AlbumFolderName returns the name of the album where the media would be stored AlbumFolderName() string // UniqueIdentifier is identifying the media no matter its filename, its id in the catalog (if it's in it or not), its album, ... It's its signature. UniqueIdentifier() string // MediaId is the id of the media in the catalog and in the archive MediaId() string }
CatalogReference is used to project where a media will fit in the catalog: its ID and its album.
type CatalogReferencerObserver ¶ added in v1.6.32
type CatalogReferencerObserver interface {
OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
}
type CatalogReferencerObserverFunc ¶ added in v1.6.35
type CatalogReferencerObserverFunc func(ctx context.Context, requests []BackingUpMediaRequest) error
func (CatalogReferencerObserverFunc) OnMediaCatalogued ¶ added in v1.6.35
func (c CatalogReferencerObserverFunc) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
type Cataloguer ¶ added in v1.6.32
type Cataloguer interface {
Reference(ctx context.Context, medias []*AnalysedMedia, observer CatalogReferencerObserver) error
}
func NewReferencer ¶ added in v1.6.32
func NewReferencer(owner ownermodel.Owner, dryRun bool) (Cataloguer, error)
type CataloguerFactory ¶ added in v1.6.35
type CataloguerFactory interface { // NewAlbumCreatorCataloguer returns a Referencer that will create the album if the date is not yet covered. NewAlbumCreatorCataloguer(ctx context.Context, owner ownermodel.Owner) (Cataloguer, error) // NewDryRunCataloguer returns a Referencer that will not create any album. NewDryRunCataloguer(ctx context.Context, owner ownermodel.Owner) (Cataloguer, error) }
type CataloguerFilter ¶ added in v1.6.32
type CataloguerFilter interface { // FilterOut returns an error if the media must be filtered out FilterOut(ctx context.Context, media AnalysedMedia, reference CatalogReference) error }
type CataloguerFilterObserver ¶ added in v1.6.32
type CataloguerFilterObserver interface {
OnFilteredOut(ctx context.Context, media AnalysedMedia, reference CatalogReference, cause error) error
}
type CataloguerObserver ¶ added in v1.6.32
type CataloguerObserver interface { CatalogReferencerObserver CataloguerFilterObserver }
type CataloguerWithFilters ¶ added in v1.6.32
type CataloguerWithFilters struct { Delegate Cataloguer CataloguerFilters []CataloguerFilter CatalogReferencerObserver CatalogReferencerObserver CataloguerFilterObserver CataloguerFilterObserver }
func (*CataloguerWithFilters) Catalog ¶ added in v1.6.32
func (c *CataloguerWithFilters) Catalog(ctx context.Context, medias []*AnalysedMedia) error
type ChannelPublisher ¶ added in v1.6.26
type ChannelPublisher struct { FoundChannel chan FoundMedia AnalysedMediaChannel chan *AnalysedMedia BufferedAnalysedChannel chan []*AnalysedMedia CataloguedChannel chan *BackingUpMediaRequest BufferedCataloguedChannel chan []*BackingUpMediaRequest CompletionChannel chan []error }
func NewAsyncPublisher ¶ added in v1.6.26
func NewAsyncPublisher(sizeHint int, batchSize int) *ChannelPublisher
NewAsyncPublisher observes step outputs and publishes them on a channel for the next one to consume
func (*ChannelPublisher) AnalysedMediaChannelCloser ¶ added in v1.6.26
func (a *ChannelPublisher) AnalysedMediaChannelCloser()
func (*ChannelPublisher) CataloguedChannelCloser ¶ added in v1.6.32
func (a *ChannelPublisher) CataloguedChannelCloser()
func (*ChannelPublisher) OnAnalysedMedia ¶ added in v1.6.26
func (a *ChannelPublisher) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
func (*ChannelPublisher) OnMediaCatalogued ¶ added in v1.6.32
func (a *ChannelPublisher) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
func (*ChannelPublisher) WaitToFinish ¶ added in v1.6.26
func (a *ChannelPublisher) WaitToFinish() []error
type ClosableFoundMedia ¶
type ClosableFoundMedia interface {
Close() error
}
ClosableFoundMedia can be implemented alongside FoundMedia if the implementation requires to release resources once the media has been handled.
type CompletionReport ¶
type CompletionReport interface { Skipped() MediaCounter CountPerAlbum() map[string]*AlbumReport }
func Backup ¶
func Backup(owner ownermodel.Owner, volume SourceVolume, optionsSlice ...Options) (CompletionReport, error)
Backup is analysing each media and is backing it up if not already in the catalog.
type CompositeRunnerObserver ¶ added in v1.6.26
type CompositeRunnerObserver struct {
Observers []interface{}
}
CompositeRunnerObserver dispatches events to multiple observers of different types
func (*CompositeRunnerObserver) OnAnalysedMedia ¶ added in v1.6.26
func (c *CompositeRunnerObserver) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
func (*CompositeRunnerObserver) OnFilteredOut ¶ added in v1.6.32
func (c *CompositeRunnerObserver) OnFilteredOut(ctx context.Context, media AnalysedMedia, reference CatalogReference, cause error) error
func (*CompositeRunnerObserver) OnMediaCatalogued ¶ added in v1.6.32
func (c *CompositeRunnerObserver) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
func (*CompositeRunnerObserver) OnRejectedMedia ¶ added in v1.6.26
func (c *CompositeRunnerObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
type ConcurrencyParameters ¶ added in v1.6.35
type ConcurrencyParameters struct { ConcurrentAnalyserRoutines int // ConcurrentAnalyserRoutines is the number of concurrent analyser (read files, compute hash, filter out duplicates, ...) ConcurrentCataloguerRoutines int // ConcurrentCataloguerRoutines is the number of concurrent cataloguer (find album, create new albums) ConcurrentUploaderRoutines int // ConcurrentUploaderRoutines is the number of concurrent uploader (upload files) }
func (ConcurrencyParameters) NumberOfConcurrentAnalyserRoutines ¶ added in v1.6.35
func (c ConcurrencyParameters) NumberOfConcurrentAnalyserRoutines() int
func (ConcurrencyParameters) NumberOfConcurrentCataloguerRoutines ¶ added in v1.6.35
func (c ConcurrencyParameters) NumberOfConcurrentCataloguerRoutines() int
func (ConcurrencyParameters) NumberOfConcurrentUploaderRoutines ¶ added in v1.6.35
func (c ConcurrencyParameters) NumberOfConcurrentUploaderRoutines() int
type CopyRejectsObserver ¶ added in v1.6.27
type CopyRejectsObserver struct {
RejectDir string
}
func (*CopyRejectsObserver) OnRejectedMedia ¶ added in v1.6.27
func (c *CopyRejectsObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
type CoreAnalyser ¶ added in v1.6.26
type CoreAnalyser struct {
// contains filtered or unexported fields
}
func (*CoreAnalyser) Analyse ¶ added in v1.6.26
func (a *CoreAnalyser) Analyse(ctx context.Context, found FoundMedia, analysedMediaObserver AnalysedMediaObserver, rejectsObserver RejectedMediaObserver) error
type DefaultInterrupterObserver ¶ added in v1.6.26
type DefaultInterrupterObserver struct {
// contains filtered or unexported fields
}
DefaultInterrupterObserver interrupts everything EXCEPT the analyser rejects
func (*DefaultInterrupterObserver) Cancel ¶ added in v1.6.26
func (c *DefaultInterrupterObserver) Cancel()
func (*DefaultInterrupterObserver) OnRejectedMedia ¶ added in v1.6.27
func (c *DefaultInterrupterObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
type DetailsReaderAdapter ¶
type DetailsReaderAdapter interface { // Supports returns true if the file can be parsed with this reader. False otherwise. Supports(media FoundMedia, mediaType MediaType) bool // ReadDetails extracts metadata from the content of the file. ReadDetails(reader io.Reader, options DetailsReaderOptions) (*MediaDetails, error) }
type DetailsReaderOptions ¶
type DetailsReaderOptions struct {
Fast bool // Fast true indicate the parser should focus at extracting the date, nothing else TODO can be retired
}
type ExtraCounts ¶ added in v1.6.27
type ExtraCounts struct { Cached MediaCounter Rejected MediaCounter }
func (ExtraCounts) String ¶ added in v1.6.27
func (c ExtraCounts) String() interface{}
type FoundMedia ¶
type FoundMedia interface { // MediaPath return breakdown of the absolute path of the media. MediaPath() MediaPath // ReadMedia reads content of the file ; it might not be optimised to call it several times (see VolumeToBackup) ReadMedia() (io.ReadCloser, error) // Size returns the size of the file Size() int LastModification() time.Time String() string }
FoundMedia represents files found on the scanned volume
func NewInMemoryMedia ¶ added in v1.5.0
func NewInMemoryMedia(name string, date time.Time, content []byte) FoundMedia
NewInMemoryMedia creates a new FoundMedia for TESTING PURPOSE ONLY
type FullMediaSignature ¶
FullMediaSignature is the business key of the media, unique per user
func (*FullMediaSignature) String ¶
func (s *FullMediaSignature) String() string
type IErrorCollectorObserver ¶ added in v1.6.27
type IErrorCollectorObserver interface { RejectedMediaObserver Errors() []error // contains filtered or unexported methods }
type ImageOrientation ¶
type ImageOrientation string
ImageOrientation is teh start point of stored data
type InMemoryMedia ¶ added in v1.5.0
type InMemoryMedia struct {
// contains filtered or unexported fields
}
func (*InMemoryMedia) LastModification ¶ added in v1.5.0
func (i *InMemoryMedia) LastModification() time.Time
func (*InMemoryMedia) MediaPath ¶ added in v1.5.0
func (i *InMemoryMedia) MediaPath() MediaPath
func (*InMemoryMedia) ReadMedia ¶ added in v1.5.0
func (i *InMemoryMedia) ReadMedia() (io.ReadCloser, error)
func (*InMemoryMedia) Size ¶ added in v1.5.0
func (i *InMemoryMedia) Size() int
func (*InMemoryMedia) String ¶ added in v1.5.0
func (i *InMemoryMedia) String() string
type InsertMediaPort ¶ added in v1.5.57
type InsertMediaPort interface {
IndexMedias(ctx context.Context, owner ownermodel.Owner, requests []*CatalogMediaRequest) error
}
type Interrupter ¶ added in v1.6.26
type Interrupter interface { RejectedMediaObserver Cancel() }
func NewInterrupterObserver ¶ added in v1.6.26
NewInterrupterObserver creates a context that will be cancelled when an error occurs
type MediaCounter ¶
type MediaCounter struct { Count int // Count is the number of medias Size int // Size is the sum of the size of the medias }
func NewMediaCounter ¶
func NewMediaCounter(count int, size int) MediaCounter
func (MediaCounter) Add ¶
func (c MediaCounter) Add(count int, size int) MediaCounter
Add creates a new MediaCounter with the delta applied ; initial MediaCounter is not updated.
func (MediaCounter) AddCounter ¶
func (c MediaCounter) AddCounter(counter MediaCounter) MediaCounter
AddCounter creates a new MediaCounter which is the sum of the 2 counters provided.
func (MediaCounter) IsZero ¶
func (c MediaCounter) IsZero() bool
IsZero returns true if it's the default value
type MediaDetails ¶
type MediaDetails struct {
Width, Height int
DateTime time.Time
Orientation ImageOrientation
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')
}
func (*MediaDetails) String ¶
func (s *MediaDetails) String() string
type MediaPath ¶
type MediaPath struct { ParentFullPath string // ParentFullPath is the absolute path of the media folder (URL = ParentFullPath + Filename) Root string // Root is the path or URL representing the volume in which the media has been found. (URL = Root + Path + Filename) Path string // Path is the directory path relative to Root: URL = Root + Path + Filename Filename string // Filename does not contain any slash, and contains the extension ParentDir string // ParentDir is the name of the directory: dirname(Root + Path) }
MediaPath is a breakdown of an absolute path, or URL, agnostic of its origin.
type NopeAnalyserDecorator ¶ added in v1.5.0
type NopeAnalyserDecorator struct { }
NopeAnalyserDecorator is a default implementation for AnalyserDecorator which doesn't decorate the AnalyseMediaFunc.
func (*NopeAnalyserDecorator) Decorate ¶ added in v1.5.0
func (n *NopeAnalyserDecorator) Decorate(analyseFunc Analyser, observers ...AnalyserDecoratorObserver) Analyser
type Options ¶
type Options struct { RestrictedAlbumFolderName map[string]interface{} // RestrictedAlbumFolderName will restrict the media to only back up medias that are in one of these albums Listener interface{} // Listener will receive progress events. SkipRejects bool // SkipRejects mode will report any analysis error, or missing timestamp, and continue. AnalyserDecorator AnalyserDecorator // AnalyserDecorator is an optional decorator to add concept like caching (might be nil) DryRun bool // DryRun mode will not upload anything and do not create albums, still analyse ConcurrencyParameters ConcurrencyParameters BatchSize int // BatchSize is the number of items to read from the database at once (used by analyser) ; default to the maximum DynamoDB can handle RejectDir string // RejectDir is the directory where rejected files will be copied }
func OptionOnlyAlbums ¶
OptionOnlyAlbums restricts backed up medias to those in these albums
func OptionWithListener ¶
func OptionWithListener(listener interface{}) Options
OptionWithListener creates an option with a listener
func OptionWithRejectDir ¶ added in v1.6.27
func OptionsBatchSize ¶ added in v1.6.35
func OptionsConcurrentAnalyserRoutines ¶ added in v1.6.35
func OptionsConcurrentCataloguerRoutines ¶ added in v1.6.35
func OptionsConcurrentUploaderRoutines ¶ added in v1.6.35
func OptionsSkipRejects ¶ added in v1.6.35
OptionsSkipRejects disables the strict mode and ignores invalid files (wrong / no date, ...)
func ReduceOptions ¶ added in v1.6.27
func (Options) GetAnalyserDecorator ¶ added in v1.5.0
func (o Options) GetAnalyserDecorator() AnalyserDecorator
GetAnalyserDecorator is returning the AnalyserDecorator or NopeAnalyserDecorator, never nil.
func (Options) GetBatchSize ¶ added in v1.6.35
func (Options) WithCachedAnalysis ¶ added in v1.5.0
func (o Options) WithCachedAnalysis(analyserDecorator AnalyserDecorator) Options
WithCachedAnalysis adds a decorator on analysis function ; argument can be nil.
type PostAnalyseFilter ¶
type PostAnalyseFilter interface { // AcceptAnalysedMedia returns TRUE if the media should be backed-up. AcceptAnalysedMedia(media *AnalysedMedia, folderName string) bool }
type ProgressObserver ¶ added in v1.6.26
type ProgressObserver struct {
EventChannel chan *progressEvent
}
func NewProgressObserver ¶ added in v1.6.26
func NewProgressObserver(sizeHint int) *ProgressObserver
NewProgressObserver publishes on a channel the progress of the backup
func (*ProgressObserver) OnAnalysedMedia ¶ added in v1.6.26
func (p *ProgressObserver) OnAnalysedMedia(ctx context.Context, media *AnalysedMedia) error
func (*ProgressObserver) OnDecoratedAnalyser ¶ added in v1.6.26
func (p *ProgressObserver) OnDecoratedAnalyser(ctx context.Context, found FoundMedia, cacheHit bool) error
func (*ProgressObserver) OnDuplicatedBackupMediaRequest ¶ added in v1.6.35
func (p *ProgressObserver) OnDuplicatedBackupMediaRequest(ctx context.Context, request []BackingUpMediaRequest) error
func (*ProgressObserver) OnFilteredOut ¶ added in v1.6.32
func (p *ProgressObserver) OnFilteredOut(ctx context.Context, media AnalysedMedia, reference CatalogReference, cause error) error
func (*ProgressObserver) OnMediaCatalogued ¶ added in v1.6.32
func (p *ProgressObserver) OnMediaCatalogued(ctx context.Context, requests []BackingUpMediaRequest) error
func (*ProgressObserver) OnRejectedMedia ¶ added in v1.6.26
func (p *ProgressObserver) OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error
func (*ProgressObserver) OnUniqueBackupMediaRequest ¶ added in v1.6.35
func (p *ProgressObserver) OnUniqueBackupMediaRequest(ctx context.Context, request []BackingUpMediaRequest) error
type RejectedMediaObserver ¶ added in v1.6.26
type RejectedMediaObserver interface { // OnRejectedMedia is called when the media is invalid and cannot be used ; the error is returned only if there is a technical issue. OnRejectedMedia(ctx context.Context, found FoundMedia, cause error) error }
func NewCopyRejectsObserver ¶ added in v1.6.27
func NewCopyRejectsObserver(rejectDir string) (RejectedMediaObserver, error)
type RunnerUploader ¶ added in v1.5.57
type RunnerUploader interface {
Upload(buffer []*BackingUpMediaRequest, progressChannel chan *progressEvent) error
}
type RunnerUploaderFunc ¶ added in v1.5.57
type RunnerUploaderFunc func(buffer []*BackingUpMediaRequest, progressChannel chan *progressEvent) error
func (RunnerUploaderFunc) Upload ¶ added in v1.5.57
func (r RunnerUploaderFunc) Upload(buffer []*BackingUpMediaRequest, progressChannel chan *progressEvent) error
type ScannedFolder ¶
type ScannedFolder struct { Name string RelativePath string // RelativePath can be used for display purpose FolderName string // FolderName is the original folder name (Name with date prefix that have been removed) AbsolutePath string // AbsolutePath is used to create a new SourceVolume Start, End time.Time // Start and End are the beginning of the day of the first media, and the beginning of the day following the last media. Distribution map[string]MediaCounter // Distribution is the number of media found for each day (format YYYY-MM-DD) RejectsCount int // RejectsCount is the number of media that have been rejected or filtered out in the folder }
ScannedFolder represents a (sub)folder in the scanned target
func (*ScannedFolder) PushBoundaries ¶
func (f *ScannedFolder) PushBoundaries(date time.Time, size int)
PushBoundaries is updating the ScannedFolder dates, and update the counter.
type SourceVolume ¶
type SourceVolume interface { String() string FindMedias() ([]FoundMedia, error) }
type TimelineAdapter ¶
type TrackAnalysed ¶
type TrackAnalysed interface {
OnAnalysed(done, total MediaCounter, others ExtraCounts)
}
type TrackEvents ¶
type TrackEvents interface {
OnEvent(event progressEvent)
}
type TrackScanComplete ¶
type TrackScanComplete interface {
OnScanComplete(total MediaCounter)
}
type TrackUploaded ¶
type TrackUploaded interface {
OnUploaded(done, total MediaCounter)
}
TrackUploaded includes both uploaded and skipped
type Tracker ¶
type Tracker struct { Done chan struct{} // Done is closed when all events have been processed. // contains filtered or unexported fields }
Tracker is simplifying the consumption of events from scans and backups to implement progress bars.
func NewTracker ¶
func NewTracker(progressChannel chan *progressEvent, listeners ...interface{}) *Tracker
NewTracker creates the Tracker and start consuming (async)
func (*Tracker) CountPerAlbum ¶
func (t *Tracker) CountPerAlbum() map[string]*AlbumReport
func (*Tracker) MediaCount ¶ added in v1.6.13
func (*Tracker) Skipped ¶
func (t *Tracker) Skipped() MediaCounter
func (*Tracker) WaitToComplete ¶
func (t *Tracker) WaitToComplete()
type Uploader ¶ added in v1.5.57
type Uploader struct { Owner ownermodel.Owner InsertMediaPort InsertMediaPort }
func (*Uploader) Upload ¶ added in v1.5.57
func (u *Uploader) Upload(buffer []*BackingUpMediaRequest, progressChannel chan *progressEvent) error
Source Files
¶
- adapters.go
- backup.go
- foundmedia_inmemory.go
- model_media.go
- model_report.go
- model_scan.go
- options.go
- runner.go
- runner_analyser.go
- runner_analyser_core.go
- runner_async_error_collector.go
- runner_async_interrupter.go
- runner_async_progress.go
- runner_async_publishers.go
- runner_cataloger_v2.go
- runner_cataloger_v2_filters.go
- runner_composite_observer.go
- runner_copy_rejects.go
- runner_executor_scan.go
- runner_executor_uploader.go
- runner_publisher.go
- runner_unique_filter.go
- scan.go
- scan_buffer.go
- scan_chain.go
- scan_flusher.go
- scan_logger.go
- scan_monitoring.go
- scan_multithreaded.go
- tracker.go
- tracker_v2.go