From fe231af7fcff92cafccb9ecde77b3455d12dab88 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 4 Jan 2015 20:07:30 +0100 Subject: [PATCH] Remove error from return value of NewContentHandler --- archiver.go | 5 +---- cmd/restic/cmd_cat.go | 5 +---- cmd/restic/cmd_find.go | 6 +----- cmd/restic/cmd_fsck.go | 5 +---- cmd/restic/cmd_ls.go | 2 +- cmd/restic/cmd_snapshots.go | 5 +---- contenthandler.go | 4 ++-- restorer.go | 5 +---- 8 files changed, 9 insertions(+), 28 deletions(-) diff --git a/archiver.go b/archiver.go index af1e4a42d..c3d1b8e54 100644 --- a/archiver.go +++ b/archiver.go @@ -55,10 +55,7 @@ func NewArchiver(s Server, p *Progress) (*Archiver, error) { arch.Filter = func(string, os.FileInfo) bool { return true } arch.bl = NewBlobList() - arch.ch, err = NewContentHandler(s) - if err != nil { - return nil, err - } + arch.ch = NewContentHandler(s) // load all blobs from all snapshots err = arch.ch.LoadAllMaps() diff --git a/cmd/restic/cmd_cat.go b/cmd/restic/cmd_cat.go index 2ee657bc3..47acbe38e 100644 --- a/cmd/restic/cmd_cat.go +++ b/cmd/restic/cmd_cat.go @@ -53,10 +53,7 @@ func (cmd CmdCat) Execute(args []string) error { } } - ch, err := restic.NewContentHandler(s) - if err != nil { - return err - } + ch := restic.NewContentHandler(s) switch tpe { case "blob": diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index 55cec11be..544d5be28 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -113,11 +113,7 @@ func (c CmdFind) findInTree(ch *restic.ContentHandler, id backend.ID, path strin func (c CmdFind) findInSnapshot(s restic.Server, id backend.ID) error { debug("searching in snapshot %s\n for entries within [%s %s]", id, c.oldest, c.newest) - ch, err := restic.NewContentHandler(s) - if err != nil { - return err - } - + ch := restic.NewContentHandler(s) sn, err := ch.LoadSnapshot(id) if err != nil { return err diff --git a/cmd/restic/cmd_fsck.go b/cmd/restic/cmd_fsck.go index 44e8b307d..033a650a6 100644 --- a/cmd/restic/cmd_fsck.go +++ b/cmd/restic/cmd_fsck.go @@ -125,10 +125,7 @@ func fsckTree(opts CmdFsck, ch *restic.ContentHandler, id backend.ID) error { func fsck_snapshot(opts CmdFsck, s restic.Server, id backend.ID) error { debug("checking snapshot %v\n", id) - ch, err := restic.NewContentHandler(s) - if err != nil { - return err - } + ch := restic.NewContentHandler(s) sn, err := ch.LoadSnapshot(id) if err != nil { diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index e769ee456..037d6b488 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -78,7 +78,7 @@ func (cmd CmdLs) Execute(args []string) error { return err } - ch, err := restic.NewContentHandler(s) + ch := restic.NewContentHandler(s) if err != nil { return err } diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go index 5432d29ae..1a1a7c25b 100644 --- a/cmd/restic/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -97,10 +97,7 @@ func (cmd CmdSnapshots) Execute(args []string) error { return err } - ch, err := restic.NewContentHandler(s) - if err != nil { - return err - } + ch := restic.NewContentHandler(s) tab := NewTable() tab.Header = fmt.Sprintf("%-8s %-19s %-10s %s", "ID", "Date", "Source", "Directory") diff --git a/contenthandler.go b/contenthandler.go index cba3dc833..202ae9049 100644 --- a/contenthandler.go +++ b/contenthandler.go @@ -17,13 +17,13 @@ type ContentHandler struct { } // NewContentHandler creates a new content handler. -func NewContentHandler(s Server) (*ContentHandler, error) { +func NewContentHandler(s Server) *ContentHandler { ch := &ContentHandler{ s: s, bl: NewBlobList(), } - return ch, nil + return ch } // LoadSnapshot adds all blobs from a snapshot into the content handler and returns the snapshot. diff --git a/restorer.go b/restorer.go index b57d83e77..c8d4b2d5b 100644 --- a/restorer.go +++ b/restorer.go @@ -25,10 +25,7 @@ func NewRestorer(s Server, snid backend.ID) (*Restorer, error) { r := &Restorer{s: s} var err error - r.ch, err = NewContentHandler(s) - if err != nil { - return nil, arrar.Annotate(err, "create contenthandler for restorer") - } + r.ch = NewContentHandler(s) r.sn, err = r.ch.LoadSnapshot(snid) if err != nil {