Documentation ¶
Overview ¶
This package implements a simple disk-persisted content-addressed blobstore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSuchKey signals that a blob with the given key does // not exist in the BlobStore. ErrNoSuchKey = errors.New("blobstore: no such key") // ErrBadKey signals that the given key is not well formed. ErrBadKey = errors.New("blobstore: bad key") )
Functions ¶
This section is empty.
Types ¶
type BlobStore ¶
type BlobStore struct {
// contains filtered or unexported fields
}
BlobStore represents a simple disk-persisted content addressible blob store that uses the file system for persistence.
Blobs in the blobstore are indexed by their SHA1 hash.
The BlobStore is backed by a directory on the filesystem. This directory contains subdirectories which contain keys (SHA1 hashes). Each subdirectory is named according to the first hex-encoded byte of the keys that subdirectory contains.
For example, a file that has the content 'hello world' will have the SHA1 hash '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'. If our blobstore's backing directory is called 'blobstore', the blob with only 'hello world' in it will be stored as follows:
blobstore/2a/2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
The BlobStore is self-synchronizing, relying on the filesystem operations to ensure atomicity. Thus, accessing a single BlobStore from multiple goroutines should have no ill side effects.
func Open ¶
Open opens an existing BlobStore. The path parameter must point to a directory that already exists for correct operation, however, the Open function does not check that this is the case.
type EOFHashMismatchError ¶
type EOFHashMismatchError struct { // Sum represents that was calculated during the read operation. Sum []byte }
EOFHashMismatchError signals that a blobReader reached EOF, but that the calculated hash did not match the given blob key. This signals a successful read of the blob, but that the on-disk content is corrupted in some fashion.
func (EOFHashMismatchError) Error ¶
func (hme EOFHashMismatchError) Error() string