Documentation ¶
Index ¶
- Constants
- func DataNameFrom(source string) string
- func IsMetaFileName(source string) bool
- func MetaNameFrom(source string) string
- func Sha256(source io.Reader) (string, int64, error)
- func ValidateMeta(bytes []byte) error
- type File
- type HashFn
- type List
- func (l List) ByName() map[string]*File
- func (l List) Data() List
- func (l List) Filter(fn func(*File) bool) List
- func (l List) Invalid() List
- func (l List) Len() int
- func (l List) Less(i, j int) bool
- func (l List) Meta() List
- func (l List) Names() []string
- func (l List) Swap(i, j int)
- func (l List) Valid() List
- type Meta
Constants ¶
const MetaFileMaxSize = 256 * 1024
MetaFileMaxSize defines the maximum size allowed for metadata files. This is only enforced to prevent memorybox from decoding potentially huge JSON blobs to see if they are memorybox metadata vs just regular ol' json. This value can be increased if a real world use-case dictates it.
const MetaFilePrefix = "meta-"
MetaFilePrefix controls naming for metadata files (which are named the same as the file they describe plus this prefix).
const MetaKey = "meta"
MetaKey is the key in metadata json files under which memorybox controls the content automatically.
const MetaKeyFileName = MetaKey + ".file"
MetaKeyFileName refers to the location where memorybox stores the name of the datafile that a metafile describes.
const MetaKeyImport = MetaKey + ".import"
MetaKeyImport refers to the location where memorybox stores details about when a file was imported.
const MetaKeyImportSet = MetaKeyImport + ".set"
MetaKeyImportSet refers to the location where memorybox stores details about what grouping of files a given file was imported with.
const MetaKeyImportSource = MetaKeyImport + ".source"
MetaKeyImportSource refers to the location where memorybox stores a string value that represents the original source a user supplied when putting a datafile into the store.
const MetaMemoryboxKey = MetaKey + ".memorybox"
MetaMemoryboxKey is the key under meta that is set to true to indicate the metadata belongs to memorybox.
Variables ¶
This section is empty.
Functions ¶
func DataNameFrom ¶
DataNameFrom calculates a datafile name from a metafile name.
func IsMetaFileName ¶
IsMetaFileName determines if a given source string is named like a metafile.
func MetaNameFrom ¶
MetaNameFrom calculates a metafile name for a data file.
func ValidateMeta ¶
ValidateMeta determines if a given set of bytes matches the metaFile format.
Types ¶
type File ¶
type File struct { Name string Source string Size int64 LastModified time.Time Body io.Reader Meta *Meta }
File is an OS and storage system agnostic representation of a file.
func New ¶
New creates a new instance of a file and names it by hashing the content of the supplied reader.
func (*File) CurrentWith ¶
CurrentWith calculates if an alternative file is considered to be "current" with this one. This is used by the sync system to determine if a file in one store should be copied to another.
type List ¶
type List []*File
List provides a listing of files that can be reasoned about with memorybox semantics. It also satisfies the sort.Sortable interface.
func (List) Filter ¶
Filter returns a new index where each file has been kept or discarded on based on the result of processing it with the supplied predicate function.
type Meta ¶
type Meta []byte
Meta holds JSON encoded metadata.
func NewMetaFromFile ¶
NewMetaFromFile produces memorybox formatted metadata from a supplied file.
func (Meta) DataFileName ¶
DataFileName extracts the datafile this metadata describes.
func (*Meta) Merge ¶
Merge takes an object and assigns every key into the meta field except managed ones.