2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

Report errors, ignore files and continue. Closes #108

This commit is contained in:
Alexander Neumann 2015-03-15 15:48:05 +01:00
parent 1bb82afcf6
commit 71a57537ef
2 changed files with 23 additions and 4 deletions

View File

@ -395,7 +395,12 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
// check for errors
if e.Error() != nil {
debug.Log("Archiver.fileWorker", "job %v has errors: %v", e.Path(), e.Error())
panic(e.Error())
// TODO: integrate error reporting
fmt.Fprintf(os.Stderr, "error for %v: %v\n", e.Path(), e.Error())
// ignore this file
e.Result() <- nil
p.Report(Stat{Files: 1})
continue
}
node, err := NodeFromFileInfo(e.Fullpath(), e.Info())
@ -432,7 +437,12 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
debug.Log("Archiver.fileWorker", " read and save %v, content: %v", e.Path(), node.Content)
node.blobs, err = arch.SaveFile(p, node)
if err != nil {
panic(err)
// TODO: integrate error reporting
fmt.Fprintf(os.Stderr, "error for %v: %v\n", node.path, err)
// ignore this file
e.Result() <- nil
p.Report(Stat{Files: 1})
continue
}
} else {
// report old data size
@ -467,7 +477,16 @@ func (arch *Archiver) dirWorker(wg *sync.WaitGroup, p *Progress, done <-chan str
// wait for all content
for _, ch := range dir.Entries {
node := (<-ch).(*Node)
res := <-ch
// if we get a nil pointer here, an error has happened while
// processing this entry. Ignore it for now.
if res == nil {
continue
}
// else insert node
node := res.(*Node)
tree.Insert(node)
if node.Type == "dir" {

View File

@ -130,7 +130,7 @@ func walk(basedir, dir string, done chan struct{}, jobs chan<- Job, res chan<- R
fi, err := os.Lstat(subpath)
if err != nil {
select {
case jobs <- Entry{info: fi, error: err, result: ch}:
case jobs <- Entry{info: fi, error: err, basedir: basedir, path: filepath.Join(relpath, name), result: ch}:
case <-done:
return errCancelled
}