mirror of
https://github.com/restic/restic.git
synced 2025-08-14 06:29:28 +00:00
restore: print processed files at maximum verbosity
This commit is contained in:
@@ -7,12 +7,14 @@ import (
|
||||
)
|
||||
|
||||
type jsonPrinter struct {
|
||||
terminal term
|
||||
terminal term
|
||||
verbosity uint
|
||||
}
|
||||
|
||||
func NewJSONProgress(terminal term) ProgressPrinter {
|
||||
func NewJSONProgress(terminal term, verbosity uint) ProgressPrinter {
|
||||
return &jsonPrinter{
|
||||
terminal: terminal,
|
||||
terminal: terminal,
|
||||
verbosity: verbosity,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +41,34 @@ func (t *jsonPrinter) Update(p State, duration time.Duration) {
|
||||
t.print(status)
|
||||
}
|
||||
|
||||
func (t *jsonPrinter) CompleteItem(messageType ItemAction, item string, size uint64) {
|
||||
if t.verbosity < 3 {
|
||||
return
|
||||
}
|
||||
|
||||
var action string
|
||||
switch messageType {
|
||||
case ActionDirRestored:
|
||||
action = "restored"
|
||||
case ActionFileRestored:
|
||||
action = "restored"
|
||||
case ActionFileUpdated:
|
||||
action = "updated"
|
||||
case ActionFileUnchanged:
|
||||
action = "unchanged"
|
||||
default:
|
||||
panic("unknown message type")
|
||||
}
|
||||
|
||||
status := verboseUpdate{
|
||||
MessageType: "verbose_status",
|
||||
Action: action,
|
||||
Item: item,
|
||||
Size: size,
|
||||
}
|
||||
t.print(status)
|
||||
}
|
||||
|
||||
func (t *jsonPrinter) Finish(p State, duration time.Duration) {
|
||||
status := summaryOutput{
|
||||
MessageType: "summary",
|
||||
@@ -65,6 +95,13 @@ type statusUpdate struct {
|
||||
BytesSkipped uint64 `json:"bytes_skipped,omitempty"`
|
||||
}
|
||||
|
||||
type verboseUpdate struct {
|
||||
MessageType string `json:"message_type"` // "verbose_status"
|
||||
Action string `json:"action"`
|
||||
Item string `json:"item"`
|
||||
Size uint64 `json:"size"`
|
||||
}
|
||||
|
||||
type summaryOutput struct {
|
||||
MessageType string `json:"message_type"` // "summary"
|
||||
SecondsElapsed uint64 `json:"seconds_elapsed,omitempty"`
|
||||
|
Reference in New Issue
Block a user