Documentation ¶
Overview ¶
Package fragment manages the fragment cache used to upload files to the server. The fragment cache lets files be uploaded in pieces, and then be copied to tape as a single unit. Files are intended to be uploaded as consecutive pieces, of arbitrary size. If a fragment upload does not complete or has and error, that fragment is deleted, and the upload can try again.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileEntry ¶
type FileEntry interface { // Return a writer which will append a new block to this file. Append() (io.WriteCloser, error) // Open the file for reading from the very beginning Open() io.ReadCloser // Stat returns information about this file Stat() Stat // Rollback deletes the last block of this file. (i.e. the last // segment of data which was Appended) Rollback() error // Set the creator name for this file. SetCreator(name string) // Set the expected MD5 sum for the entire file (i.e. over all of // its blocks). SetMD5(hash []byte) // Set the expected SHA256 sum for the entire file (i.e. over all of // its blocks). SetSHA256(hash []byte) // Set the mime-type of this file. SetMimeType(mimetype string) // Sets an opaque metadata blob which can be assigned to each file. SetExtra(extra string) // Verify the checksums of this file. Returns true if they match, // and false otherwise. Verify() (bool, error) }
A FileEntry represents a single file in the fragment store. A FileEntry presents a collection of operations which can be done on a file, including opening it for Appending, and opening it for reading. (A FileEntry cannot be read or written to directly).
type JSONStore ¶
A JSONStore wraps a Store and provides a store which serializes its items as JSON instead of using streams. It does not cache the results of serialization/deserialization. Since it deals with interface{} instead of readers and writers, a JSONStore does not match the store.Store interface.
func (JSONStore) Create ¶
Create is a synonym for Save(). (Why do we have this?) This is here to override js.Store.Create()
type Stat ¶
type Stat struct { ID string Size int64 NFragments int Created time.Time Modified time.Time Creator string MD5 []byte // expected hash for entire file SHA256 []byte // expected hash for entire file MimeType string Extra string // arbitrary user defined content }
Stat contains the metadata for a file entry.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a store.Store and provides a fragment cache. This allows files to be uploaded in pieces, "fragments", and then read back as a single unit.
func New ¶
New creates a new fragment store wrapping a store.Store. Call Load() before using the store.
func (*Store) Delete ¶
Delete deletes a file. It is not an error to delete a file that does not exist.
func (*Store) List ¶
List returns the names of all the stored files. (But not the names of the individual fragment files).
func (*Store) Load ¶
Load initializes the in-memory indexing and caches for the stored file entries. It must be called before using this store.