From 7d1ba8ab655024785d077c04f982ec44d7423320 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 23 Nov 2014 12:14:56 +0100 Subject: [PATCH] Ignore permission errors for backup --- archiver.go | 11 ++++++----- cmd/khepri/cmd_backup.go | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/archiver.go b/archiver.go index 4fa33819a..1ce7180bc 100644 --- a/archiver.go +++ b/archiver.go @@ -9,6 +9,7 @@ import ( "github.com/fd0/khepri/backend" "github.com/fd0/khepri/chunker" + "github.com/juju/arrar" ) const ( @@ -122,7 +123,7 @@ func (arch *Archiver) SaveFile(node *Node) error { file, err := os.Open(node.path) defer file.Close() if err != nil { - return err + return arrar.Annotate(err, "SaveFile()") } var blobs Blobs @@ -196,7 +197,7 @@ func (arch *Archiver) loadTree(dir string) (*Tree, error) { fd, err := os.Open(dir) defer fd.Close() if err != nil { - return nil, err + return nil, arch.Error(dir, nil, err) } entries, err := fd.Readdir(-1) @@ -247,12 +248,12 @@ func (arch *Archiver) loadTree(dir string) (*Tree, error) { func (arch *Archiver) LoadTree(path string) (*Tree, error) { fi, err := os.Lstat(path) if err != nil { - return nil, err + return nil, arrar.Annotatef(err, "Lstat(%q)", path) } node, err := NodeFromFileInfo(path, fi) if err != nil { - return nil, err + return nil, arrar.Annotate(err, "NodeFromFileInfo()") } if node.Type != "dir" { @@ -265,7 +266,7 @@ func (arch *Archiver) LoadTree(path string) (*Tree, error) { arch.Stats.Directories = 1 node.Tree, err = arch.loadTree(path) if err != nil { - return nil, err + return nil, arrar.Annotate(err, "loadTree()") } arch.ScannerUpdate(arch.Stats) diff --git a/cmd/khepri/cmd_backup.go b/cmd/khepri/cmd_backup.go index 0e3972186..8ede5da32 100644 --- a/cmd/khepri/cmd_backup.go +++ b/cmd/khepri/cmd_backup.go @@ -52,8 +52,9 @@ func commandBackup(be backend.Server, key *khepri.Key, args []string) error { fmt.Fprintf(os.Stderr, "err: %v\n", err) } arch.Error = func(dir string, fi os.FileInfo, err error) error { - fmt.Fprintf(os.Stderr, "error for %s: %v\n%v\n", dir, err, fi) - return err + // TODO: make ignoring errors configurable + fmt.Fprintf(os.Stderr, "\nerror for %s: %v\n%v\n", dir, err, fi) + return nil } fmt.Printf("scanning %s\n", target)