Merge pull request #143 from fw42/count_errors

Count errors separately and not as files that are "done"
This commit is contained in:
Alexander Neumann 2015-04-26 12:05:09 +02:00
commit 434c79354e
3 changed files with 15 additions and 12 deletions

View File

@ -403,7 +403,7 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
fmt.Fprintf(os.Stderr, "error for %v: %v\n", e.Path(), e.Error()) fmt.Fprintf(os.Stderr, "error for %v: %v\n", e.Path(), e.Error())
// ignore this file // ignore this file
e.Result() <- nil e.Result() <- nil
p.Report(Stat{Files: 1}) p.Report(Stat{Errors: 1})
continue continue
} }
@ -412,7 +412,7 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
// TODO: integrate error reporting // TODO: integrate error reporting
debug.Log("Archiver.fileWorker", "NodeFromFileInfo returned error for %v: %v", node.path, err) debug.Log("Archiver.fileWorker", "NodeFromFileInfo returned error for %v: %v", node.path, err)
e.Result() <- nil e.Result() <- nil
p.Report(Stat{Files: 1}) p.Report(Stat{Errors: 1})
continue continue
} }
@ -449,7 +449,7 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
fmt.Fprintf(os.Stderr, "error for %v: %v\n", node.path, err) fmt.Fprintf(os.Stderr, "error for %v: %v\n", node.path, err)
// ignore this file // ignore this file
e.Result() <- nil e.Result() <- nil
p.Report(Stat{Files: 1}) p.Report(Stat{Errors: 1})
continue continue
} }
} else { } else {

View File

@ -139,12 +139,13 @@ func newArchiveProgress(todo restic.Stat) *restic.Progress {
percent = 100 percent = 100
} }
status1 := fmt.Sprintf("[%s] %3.2f%% %s/s %s / %s %d / %d items ", status1 := fmt.Sprintf("[%s] %3.2f%% %s/s %s / %s %d / %d items %d errors ",
formatDuration(d), formatDuration(d),
percent, percent,
formatBytes(bps), formatBytes(bps),
formatBytes(s.Bytes), formatBytes(todo.Bytes), formatBytes(s.Bytes), formatBytes(todo.Bytes),
itemsDone, itemsTodo) itemsDone, itemsTodo,
s.Errors)
status2 := fmt.Sprintf("ETA %s ", formatSeconds(eta)) status2 := fmt.Sprintf("ETA %s ", formatSeconds(eta))
w, _, err := terminal.GetSize(int(os.Stdout.Fd())) w, _, err := terminal.GetSize(int(os.Stdout.Fd()))

View File

@ -24,11 +24,12 @@ type Progress struct {
} }
type Stat struct { type Stat struct {
Files uint64 Files uint64
Dirs uint64 Dirs uint64
Bytes uint64 Bytes uint64
Trees uint64 Trees uint64
Blobs uint64 Blobs uint64
Errors uint64
} }
type ProgressFunc func(s Stat, runtime time.Duration, ticker bool) type ProgressFunc func(s Stat, runtime time.Duration, ticker bool)
@ -154,6 +155,7 @@ func (s *Stat) Add(other Stat) {
s.Files += other.Files s.Files += other.Files
s.Trees += other.Trees s.Trees += other.Trees
s.Blobs += other.Blobs s.Blobs += other.Blobs
s.Errors += other.Errors
} }
func (s Stat) String() string { func (s Stat) String() string {
@ -173,6 +175,6 @@ func (s Stat) String() string {
str = fmt.Sprintf("%dB", s.Bytes) str = fmt.Sprintf("%dB", s.Bytes)
} }
return fmt.Sprintf("Stat(%d files, %d dirs, %v trees, %v blobs, %v)", return fmt.Sprintf("Stat(%d files, %d dirs, %v trees, %v blobs, %d errors, %v)",
s.Files, s.Dirs, s.Trees, s.Blobs, str) s.Files, s.Dirs, s.Trees, s.Blobs, s.Errors, str)
} }