Documentation ¶
Overview ¶
Package backupmodel define the common language used within backup package (between interactors, adapters, and backup consumers)
Index ¶
- Constants
- type AnalysedMedia
- type BackupReport
- type ClosableMedia
- type DetailsReaderAdapter
- type DetailsReaderOptions
- type DownloaderAdapter
- type FoundMedia
- type FoundMediaWithHash
- type FullMediaSignature
- type ImageOrientation
- type InmemoryMedia
- type InmemoryMediaWithHash
- type MediaCounter
- type MediaDetails
- type MediaPath
- type MediaScannerAdapter
- type MediaType
- type OnlineStorageAdapter
- type PostAnalyseFilter
- type ProgressEvent
- type ProgressEventType
- type ReadableMedia
- type ScannedFolder
- type SimpleMediaSignature
- type TypeCounter
- func (c *TypeCounter) GetMediaIndex(mediaType MediaType) int
- func (c *TypeCounter) IncrementCounter(counter *[numberOfMediaType]uint, mediaType MediaType, delta uint)
- func (c *TypeCounter) IncrementFoundCounter(mediaType MediaType, count uint, size uint)
- func (c *TypeCounter) OfType(mediaType MediaType) MediaCounter
- func (c *TypeCounter) Total() MediaCounter
- type VolumeMetadata
- type VolumeRepositoryAdapter
- type VolumeToBackup
- type VolumeType
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" VolumeTypeFileSystem VolumeType = "filesystem" // Mounted folder VolumeTypeS3 VolumeType = "s3" // Storage in S3 ProgressEventScanComplete ProgressEventType = "scan-complete" ProgressEventDownloaded ProgressEventType = "downloaded" ProgressEventSkipped ProgressEventType = "skipped-before-download" ProgressEventSkippedAfterAnalyse ProgressEventType = "skipped-after-analyse" ProgressEventAnalysed ProgressEventType = "analysed" ProgressEventUploaded ProgressEventType = "uploaded" ProgressEventAlbumCreated ProgressEventType = "album-created" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysedMedia ¶
type AnalysedMedia struct { FoundMedia FoundMedia // FoundMedia is the reference of the file, implementation depends on the VolumeType Type MediaType // Photo or Video Signature *FullMediaSignature // Business key of the media 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 BackupReport ¶
type BackupReport interface { NewAlbums() []string Skipped() MediaCounter CountPerAlbum() map[string]*TypeCounter WaitToComplete() }
type ClosableMedia ¶
type ClosableMedia interface {
Close() error
}
ClosableMedia can be implemented alongside FoundMedia if the implementation requires to release resources once the media has been handled.
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 determine if the reader should extract all the details it can, or should only focus on the DateTime (and other it could get in the same time)
}
type DownloaderAdapter ¶
type DownloaderAdapter interface {
DownloadMedia(media FoundMedia) (FoundMedia, error)
}
DownloaderAdapter downloads locally files that are in a slow volume as they will need to be read twice each (analyse + sha256, and upload)
type FoundMedia ¶
type FoundMedia interface { // MediaPath return breakdown of the absolute path of the media. MediaPath() MediaPath // LastModificationDate returns the dte the physical file has been last updated LastModificationDate() time.Time // SimpleSignature gets a key, unique for the volume SimpleSignature() *SimpleMediaSignature // ReadMedia reads content of the file ; it might not be optimised to call it several times (see VolumeToBackup) ReadMedia() (io.ReadCloser, error) }
func NewInmemoryMedia ¶
func NewInmemoryMedia(name string, size uint, date time.Time) FoundMedia
NewInmemoryMedia creates a new FoundMedia for TESTING PURPOSE ONLY
func NewInmemoryMediaWithHash ¶
NewInmemoryMediaWithHash creates a new InmemoryMediaWithHash. TESTING PURPOSE ONLY
type FoundMediaWithHash ¶
type FoundMediaWithHash interface {
Sha256Hash() string
}
FoundMediaWithHash can be implemented along side FoundMedia if the implementation can compute sha256 hash on the fly
type FullMediaSignature ¶
FullMediaSignature is the business key of the media, unique per user
func (*FullMediaSignature) String ¶
func (s *FullMediaSignature) String() string
type ImageOrientation ¶
type ImageOrientation string
ImageOrientation is teh start point of stored data
type InmemoryMedia ¶
type InmemoryMedia struct {
// contains filtered or unexported fields
}
func (*InmemoryMedia) LastModificationDate ¶
func (i *InmemoryMedia) LastModificationDate() time.Time
func (*InmemoryMedia) MediaPath ¶
func (i *InmemoryMedia) MediaPath() MediaPath
func (*InmemoryMedia) ReadMedia ¶
func (i *InmemoryMedia) ReadMedia() (io.ReadCloser, error)
func (*InmemoryMedia) SimpleSignature ¶
func (i *InmemoryMedia) SimpleSignature() *SimpleMediaSignature
type InmemoryMediaWithHash ¶
type InmemoryMediaWithHash struct { *InmemoryMedia // contains filtered or unexported fields }
func (*InmemoryMediaWithHash) Sha256Hash ¶
func (m *InmemoryMediaWithHash) Sha256Hash() string
type MediaCounter ¶
type MediaCounter struct { Count uint // Count is the number of medias Size uint // Size is the sum of the size of the medias }
func (MediaCounter) Add ¶
func (c MediaCounter) Add(count uint, size uint) 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 path that can be used to create a sub-volume that only contains sibling medias of this one Root string // Root is the path or URL representing the volume in which the media has been found. Path string // Path is the path between Root and Filename (ie: Root + Path + Filename would be the absolute URL) Filename string // Filename does not contain any slash, and contains the extension. ParentDir string // ParentDir is the name of the media folder ; it might be from the Path or from the Root }
MediaPath is a breakdown of an absolute path, or URL, agnostic of its origin.
type MediaScannerAdapter ¶
type MediaScannerAdapter interface { // FindMediaRecursively scan throw the VolumeToBackup and emit to the channel any media found. Interrupted in case of error. // returns number of items found, and size of these items FindMediaRecursively(volume VolumeToBackup, callback func(FoundMedia)) (uint, uint, error) }
type OnlineStorageAdapter ¶
type OnlineStorageAdapter interface { // UploadFile 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. UploadFile(owner string, media ReadableMedia, folderName, filename string) (string, error) // MoveFile moves physically a file in remote storage ; returns filename (different in case on conflict) MoveFile(owner string, folderName string, filename string, destFolderName string) (string, error) }
type PostAnalyseFilter ¶
type PostAnalyseFilter interface { // AcceptAnalysedMedia returns TRUE if the media should be backed-up. AcceptAnalysedMedia(media *AnalysedMedia, folderName string) bool }
var (
DefaultPostAnalyseFilter PostAnalyseFilter = nil
)
type ProgressEvent ¶
type ProgressEvent struct { Type ProgressEventType // Type defines what's count, and size are about ; some might not be used. Count uint // Count is the number of media Size uint // Size is the sum of the size of the media concerned by this event Album string // Album is the folder name of the medias concerned by this event MediaType MediaType // MediaType is the type of media ; only mandatory with 'uploaded' event }
type ProgressEventType ¶
type ProgressEventType string
type ReadableMedia ¶
type ReadableMedia interface { ReadMedia() (io.ReadCloser, error) // SimpleSignature is used to get the size to upload SimpleSignature() *SimpleMediaSignature }
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) 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) BackupVolume *VolumeToBackup // BackupVolume is the volume to use to back up only this specific folder, }
ScannedFolder represents a (sub)folder in the scanned target
func (*ScannedFolder) PushBoundaries ¶
func (f *ScannedFolder) PushBoundaries(date time.Time, size uint)
PushBoundaries is updating the ScannedFolder dates, and update the counter.
type SimpleMediaSignature ¶
SimpleMediaSignature is unique only for a single volume, and only for a certain time (i.e.: filename)
func (*SimpleMediaSignature) String ¶
func (s *SimpleMediaSignature) String() string
type TypeCounter ¶
type TypeCounter struct {
// contains filtered or unexported fields
}
func (*TypeCounter) GetMediaIndex ¶
func (c *TypeCounter) GetMediaIndex(mediaType MediaType) int
func (*TypeCounter) IncrementCounter ¶
func (c *TypeCounter) IncrementCounter(counter *[numberOfMediaType]uint, mediaType MediaType, delta uint)
func (*TypeCounter) IncrementFoundCounter ¶
func (c *TypeCounter) IncrementFoundCounter(mediaType MediaType, count uint, size uint)
func (*TypeCounter) OfType ¶
func (c *TypeCounter) OfType(mediaType MediaType) MediaCounter
func (*TypeCounter) Total ¶
func (c *TypeCounter) Total() MediaCounter
type VolumeMetadata ¶
type VolumeRepositoryAdapter ¶
type VolumeRepositoryAdapter interface { RestoreLastSnapshot(volumeId string) ([]SimpleMediaSignature, error) StoreSnapshot(volumeId string, backupId string, signatures []SimpleMediaSignature) error }
VolumeRepositoryAdapter keeps media found previously on a volume to not re-analyse them or request the remote server if there are already backed-up.
type VolumeToBackup ¶
type VolumeToBackup struct { UniqueId string // UniqueId represents a location unique for the computer Type VolumeType // Type is used to determine the implementation to scan and read medias Path string // Path is the absolute path or URL of the media Local bool // Local is true when files can be analysed (hash, EXIF) directly ; otherwise, they need to be copied locally first }
VolumeToBackup represents a location to backup.
func (*VolumeToBackup) String ¶
func (v *VolumeToBackup) String() string
type VolumeType ¶
type VolumeType string
VolumeType is used to choose the drive to scan and read medias from the volume