mirror of
https://github.com/restic/restic.git
synced 2026-06-24 17:44:17 +00:00
Introduce type Server
This commit is contained in:
+8
-8
@@ -11,16 +11,16 @@ import (
|
||||
var ErrWrongData = errors.New("wrong data decrypt, checksum does not match")
|
||||
|
||||
type ContentHandler struct {
|
||||
be backend.Server
|
||||
s Server
|
||||
key *Key
|
||||
|
||||
bl *BlobList
|
||||
}
|
||||
|
||||
// NewContentHandler creates a new content handler.
|
||||
func NewContentHandler(be backend.Server, key *Key) (*ContentHandler, error) {
|
||||
func NewContentHandler(s Server, key *Key) (*ContentHandler, error) {
|
||||
ch := &ContentHandler{
|
||||
be: be,
|
||||
s: s,
|
||||
key: key,
|
||||
bl: NewBlobList(),
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (ch *ContentHandler) LoadSnapshot(id backend.ID) (*Snapshot, error) {
|
||||
// into the content handler.
|
||||
func (ch *ContentHandler) LoadAllMaps() error {
|
||||
// add all maps from all snapshots that can be decrypted to the storage map
|
||||
err := backend.EachID(ch.be, backend.Map, func(id backend.ID) {
|
||||
err := backend.EachID(ch.s, backend.Map, func(id backend.ID) {
|
||||
bl, err := LoadBlobList(ch, id)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -103,7 +103,7 @@ func (ch *ContentHandler) Save(t backend.Type, data []byte) (Blob, error) {
|
||||
ciphertext = ciphertext[:n]
|
||||
|
||||
// save blob
|
||||
sid, err := ch.be.Create(t, ciphertext)
|
||||
sid, err := ch.s.Create(t, ciphertext)
|
||||
if err != nil {
|
||||
return Blob{}, err
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (ch *ContentHandler) SaveJSON(t backend.Type, item interface{}) (Blob, erro
|
||||
func (ch *ContentHandler) Load(t backend.Type, id backend.ID) ([]byte, error) {
|
||||
if t == backend.Snapshot {
|
||||
// load data
|
||||
buf, err := ch.be.Get(t, id)
|
||||
buf, err := ch.s.Get(t, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func (ch *ContentHandler) Load(t backend.Type, id backend.ID) ([]byte, error) {
|
||||
}
|
||||
|
||||
// load data
|
||||
buf, err := ch.be.Get(t, blob.Storage)
|
||||
buf, err := ch.s.Get(t, blob.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func (ch *ContentHandler) LoadJSON(t backend.Type, id backend.ID, item interface
|
||||
// decrypts it and calls json.Unmarshal on the item.
|
||||
func (ch *ContentHandler) LoadJSONRaw(t backend.Type, id backend.ID, item interface{}) error {
|
||||
// load data
|
||||
buf, err := ch.be.Get(t, id)
|
||||
buf, err := ch.s.Get(t, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user