/
support.go
36 lines (30 loc) · 1 KB
/
support.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
28
29
30
31
32
33
34
35
36
package stodiskaccess
import (
"io"
"github.com/function61/varasto/pkg/stotypes"
)
type BlobMeta struct {
Ref stotypes.BlobRef
RealSize int32
SizeOnDisk int32 // after optional compression
IsCompressed bool
EncryptionKeyId string
EncryptionKey []byte // this is set when read from QueryBlobMetadata(), but not when given to WriteBlobCreated()
ExpectedCrc32 []byte
}
type MetadataStore interface {
// returns os.ErrNotExist if ref does not exist
QueryBlobMetadata(ref stotypes.BlobRef, encryptionKeys []stotypes.KeyEnvelope) (*BlobMeta, error)
QueryBlobCrc32(ref stotypes.BlobRef) ([]byte, error)
QueryBlobExists(ref stotypes.BlobRef) (bool, error)
QueryCollectionEncryptionKeyForNewBlobs(collId string) (string, []byte, error)
WriteBlobCreated(meta *BlobMeta, volumeId int) error
WriteBlobReplicated(ref stotypes.BlobRef, volumeId int) error
}
type readCloseWrapper struct {
io.Reader
closer io.Closer
}
func (r *readCloseWrapper) Close() error {
return r.closer.Close()
}