-
Notifications
You must be signed in to change notification settings - Fork 7
/
storage.go
27 lines (23 loc) · 1.03 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package get
import (
"crypto"
"errors"
"io"
"github.com/moio/minima/util"
)
// Storage allows to store data in the form of files. Files are accumulated in
// a "temporary" location until Commit is called at that point any file in the
// temporary location is moved in the "permanent" location
type Storage interface {
// StoringMapper returns a mapper that will store read data to a temporary location specified by filename
StoringMapper(filename string, checksum string, hash crypto.Hash) util.ReaderMapper
// Commit moves any temporary file accumulated so far to the permanent location
Commit() (err error)
// NewReader returns a Reader for a file in the permanent location, returns ErrFileNotFound
// if the requested path was not found at all
NewReader(filename string) (reader io.ReadCloser, err error)
// Recycle will copy a file from the permanent to the temporary location
Recycle(filename string) (err error)
}
// ErrFileNotFound signals that the requested file was not found
var ErrFileNotFound = errors.New("File not found")