
* Add PutMetadata function to storage backends This function is not currently used, but it will be useful for helper scripts that need to regenerate metadata on the fly, especially scripts to migrate between storage backends. In the future, we can also use it to automatically regenerate metadata if it is found to be missing or corrupted. * Add PutMetadata function to storage backend interface and implementations * Rework metadata generation to be more efficient and work better with the PutMetadata function * Add a basic test for metadata generation * Change PutMetadata to take a Metadata type instead It's unlikely that this function is useful if it always regenerates the metadata. Instead, the caller should do that if it needs.
25 lines
570 B
Go
25 lines
570 B
Go
package backends
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type StorageBackend interface {
|
|
Delete(key string) error
|
|
Exists(key string) (bool, error)
|
|
Head(key string) (Metadata, error)
|
|
Get(key string) (Metadata, io.ReadCloser, error)
|
|
Put(key string, r io.Reader, expiry time.Time, deleteKey string) (Metadata, error)
|
|
PutMetadata(key string, m Metadata) error
|
|
Size(key string) (int64, error)
|
|
}
|
|
|
|
type MetaStorageBackend interface {
|
|
StorageBackend
|
|
List() ([]string, error)
|
|
}
|
|
|
|
var NotFoundErr = errors.New("File not found.")
|
|
var FileEmptyError = errors.New("Empty file")
|