mirror of
https://github.com/restic/restic.git
synced 2026-11-10 08:41:00 +00:00
archiver: pass ItemAction to progress reporter instead of data.Node (#21886)
This commit is contained in:
1 parent
57ac5d107c
commit
532f36a5a8
4 files changed
+84
-56
No files matched your search
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/archiver"
|
||||
"github.com/restic/restic/internal/data"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
@@ -118,44 +117,28 @@ func (p *Progress) CompleteBlob(bytes uint64) {
|
||||
|
||||
// CompleteItem is the status callback function for the archiver when a
|
||||
// file/dir has been saved successfully.
|
||||
func (p *Progress) CompleteItem(item string, previous, current *data.Node, s archiver.ItemStats, d time.Duration) {
|
||||
if current == nil {
|
||||
// error occurred, tell the status display to remove the line
|
||||
func (p *Progress) CompleteItem(item string, action archiver.ItemAction, s archiver.ItemStats, d time.Duration) {
|
||||
if action.IsZero() {
|
||||
// file reading completed but not fully saved, tell the status display to remove the line
|
||||
p.mu.Lock()
|
||||
delete(p.currentFiles, item)
|
||||
p.mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
switch current.Type {
|
||||
case data.NodeTypeDir:
|
||||
switch action {
|
||||
case archiver.ActionDirNew, archiver.ActionDirUnchanged, archiver.ActionDirModified:
|
||||
p.mu.Lock()
|
||||
p.addProcessed(Counter{Dirs: 1})
|
||||
p.mu.Unlock()
|
||||
p.printer.CompleteItem(string(action), item, s, d)
|
||||
|
||||
switch {
|
||||
case previous == nil:
|
||||
p.printer.CompleteItem("dir new", item, s, d)
|
||||
case previous.Equals(*current):
|
||||
p.printer.CompleteItem("dir unchanged", item, s, d)
|
||||
default:
|
||||
p.printer.CompleteItem("dir modified", item, s, d)
|
||||
}
|
||||
|
||||
case data.NodeTypeFile:
|
||||
case archiver.ActionFileNew, archiver.ActionFileUnchanged, archiver.ActionFileModified:
|
||||
p.mu.Lock()
|
||||
p.addProcessed(Counter{Files: 1})
|
||||
delete(p.currentFiles, item)
|
||||
p.mu.Unlock()
|
||||
|
||||
switch {
|
||||
case previous == nil:
|
||||
p.printer.CompleteItem("file new", item, s, d)
|
||||
case previous.Equals(*current):
|
||||
p.printer.CompleteItem("file unchanged", item, s, d)
|
||||
default:
|
||||
p.printer.CompleteItem("file modified", item, s, d)
|
||||
}
|
||||
p.printer.CompleteItem(string(action), item, s, d)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user