forked from TrueCloudLab/restic
Fix all code which uses repository.New()
This commit is contained in:
parent
f956f60f9f
commit
c0b5f5a8af
6 changed files with 24 additions and 7 deletions
|
@ -26,7 +26,11 @@ func (cmd CmdInit) Execute(args []string) error {
|
|||
"enter password again: ")
|
||||
}
|
||||
|
||||
s := repository.New(be)
|
||||
s, err := repository.New(be)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = s.Init(cmd.global.password)
|
||||
if err != nil {
|
||||
cmd.global.Exitf(1, "creating key in backend at %s failed: %v\n", cmd.global.Repo, err)
|
||||
|
|
|
@ -208,7 +208,10 @@ func (o GlobalOptions) OpenRepository() (*repository.Repository, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
s := repository.New(be)
|
||||
s, err := repository.New(be)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if o.password == "" {
|
||||
o.password = o.ReadPassword("enter password for repository: ")
|
||||
|
|
|
@ -78,7 +78,11 @@ func testArchiverDuplication(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
repo := repository.New(forgetfulBackend())
|
||||
repo, err := repository.New(forgetfulBackend())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = repo.Init("foo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -239,7 +239,8 @@ func induceError(data []byte) {
|
|||
func TestCheckerModifiedData(t *testing.T) {
|
||||
be := mem.New()
|
||||
|
||||
repo := repository.New(be)
|
||||
repo, err := repository.New(be)
|
||||
OK(t, err)
|
||||
OK(t, repo.Init(TestPassword))
|
||||
|
||||
arch := restic.NewArchiver(repo)
|
||||
|
@ -248,7 +249,8 @@ func TestCheckerModifiedData(t *testing.T) {
|
|||
t.Logf("archived as %v", id.Str())
|
||||
|
||||
beError := &errorBackend{Backend: be}
|
||||
checkRepo := repository.New(beError)
|
||||
checkRepo, err := repository.New(beError)
|
||||
OK(t, err)
|
||||
OK(t, checkRepo.SearchKey(TestPassword))
|
||||
|
||||
chkr := checker.New(checkRepo)
|
||||
|
|
|
@ -91,6 +91,9 @@ type Packer struct {
|
|||
// NewPacker returns a new Packer that can be used to pack blobs
|
||||
// together. If wr is nil, a bytes.Buffer is used.
|
||||
func NewPacker(k *crypto.Key, wr io.Writer) *Packer {
|
||||
if wr == nil {
|
||||
wr = bytes.NewBuffer(nil)
|
||||
}
|
||||
return &Packer{k: k, wr: wr}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,13 @@ func newPack(t testing.TB, k *crypto.Key) ([]Buf, []byte, uint) {
|
|||
// pack blobs
|
||||
p := pack.NewPacker(k, nil)
|
||||
for _, b := range bufs {
|
||||
p.Add(pack.Tree, b.id, bytes.NewReader(b.data))
|
||||
p.Add(pack.Tree, b.id, b.data)
|
||||
}
|
||||
|
||||
packData, err := p.Finalize()
|
||||
_, err := p.Finalize()
|
||||
OK(t, err)
|
||||
|
||||
packData := p.Writer().(*bytes.Buffer).Bytes()
|
||||
return bufs, packData, p.Size()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue