mirror of
https://github.com/octoleo/restic.git
synced 2024-11-11 07:41:03 +00:00
Fix all code which uses repository.New()
This commit is contained in:
parent
f956f60f9f
commit
c0b5f5a8af
@ -26,7 +26,11 @@ func (cmd CmdInit) Execute(args []string) error {
|
|||||||
"enter password again: ")
|
"enter password again: ")
|
||||||
}
|
}
|
||||||
|
|
||||||
s := repository.New(be)
|
s, err := repository.New(be)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = s.Init(cmd.global.password)
|
err = s.Init(cmd.global.password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.global.Exitf(1, "creating key in backend at %s failed: %v\n", cmd.global.Repo, err)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
s := repository.New(be)
|
s, err := repository.New(be)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if o.password == "" {
|
if o.password == "" {
|
||||||
o.password = o.ReadPassword("enter password for repository: ")
|
o.password = o.ReadPassword("enter password for repository: ")
|
||||||
|
@ -78,7 +78,11 @@ func testArchiverDuplication(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
repo := repository.New(forgetfulBackend())
|
repo, err := repository.New(forgetfulBackend())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
err = repo.Init("foo")
|
err = repo.Init("foo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -239,7 +239,8 @@ func induceError(data []byte) {
|
|||||||
func TestCheckerModifiedData(t *testing.T) {
|
func TestCheckerModifiedData(t *testing.T) {
|
||||||
be := mem.New()
|
be := mem.New()
|
||||||
|
|
||||||
repo := repository.New(be)
|
repo, err := repository.New(be)
|
||||||
|
OK(t, err)
|
||||||
OK(t, repo.Init(TestPassword))
|
OK(t, repo.Init(TestPassword))
|
||||||
|
|
||||||
arch := restic.NewArchiver(repo)
|
arch := restic.NewArchiver(repo)
|
||||||
@ -248,7 +249,8 @@ func TestCheckerModifiedData(t *testing.T) {
|
|||||||
t.Logf("archived as %v", id.Str())
|
t.Logf("archived as %v", id.Str())
|
||||||
|
|
||||||
beError := &errorBackend{Backend: be}
|
beError := &errorBackend{Backend: be}
|
||||||
checkRepo := repository.New(beError)
|
checkRepo, err := repository.New(beError)
|
||||||
|
OK(t, err)
|
||||||
OK(t, checkRepo.SearchKey(TestPassword))
|
OK(t, checkRepo.SearchKey(TestPassword))
|
||||||
|
|
||||||
chkr := checker.New(checkRepo)
|
chkr := checker.New(checkRepo)
|
||||||
|
@ -91,6 +91,9 @@ type Packer struct {
|
|||||||
// NewPacker returns a new Packer that can be used to pack blobs
|
// NewPacker returns a new Packer that can be used to pack blobs
|
||||||
// together. If wr is nil, a bytes.Buffer is used.
|
// together. If wr is nil, a bytes.Buffer is used.
|
||||||
func NewPacker(k *crypto.Key, wr io.Writer) *Packer {
|
func NewPacker(k *crypto.Key, wr io.Writer) *Packer {
|
||||||
|
if wr == nil {
|
||||||
|
wr = bytes.NewBuffer(nil)
|
||||||
|
}
|
||||||
return &Packer{k: k, wr: wr}
|
return &Packer{k: k, wr: wr}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,13 @@ func newPack(t testing.TB, k *crypto.Key) ([]Buf, []byte, uint) {
|
|||||||
// pack blobs
|
// pack blobs
|
||||||
p := pack.NewPacker(k, nil)
|
p := pack.NewPacker(k, nil)
|
||||||
for _, b := range bufs {
|
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)
|
OK(t, err)
|
||||||
|
|
||||||
|
packData := p.Writer().(*bytes.Buffer).Bytes()
|
||||||
return bufs, packData, p.Size()
|
return bufs, packData, p.Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user