From 5fead928e068bd7a6fe2beb0302de2aaec4ea109 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Wed, 16 Aug 2017 20:26:06 -0700 Subject: [PATCH] fixed backups and expire command output --- cli/command_backups.go | 22 ++++++++++++++-------- cli/command_expire.go | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cli/command_backups.go b/cli/command_backups.go index 4c05503d5..b75c8de0e 100644 --- a/cli/command_backups.go +++ b/cli/command_backups.go @@ -95,13 +95,8 @@ func runBackupsCommand(context *kingpin.ParseContext) error { sort.Sort(manifestSorter(manifests)) + var lastTotalFileSize int64 for _, m := range manifests { - if m.Source != lastSource { - fmt.Printf("\n%v\n", m.Source) - lastSource = m.Source - count = 0 - } - maybeIncomplete := "" if m.IncompleteReason != "" { if !*backupsIncludeIncomplete { @@ -110,6 +105,13 @@ func runBackupsCommand(context *kingpin.ParseContext) error { maybeIncomplete = " " + m.IncompleteReason } + if m.Source != lastSource { + fmt.Printf("\n%v\n", m.Source) + lastSource = m.Source + count = 0 + lastTotalFileSize = m.Stats.TotalFileSize + } + if count < *maxResultsPerPath { fmt.Printf( " %v%v %v %10v %v%v\n", @@ -117,7 +119,7 @@ func runBackupsCommand(context *kingpin.ParseContext) error { relPath, m.StartTime.Format("2006-01-02 15:04:05 MST"), units.BytesStringBase10(m.Stats.TotalFileSize), - deltaBytes(m.Stats.Repository.WrittenBytes), + deltaBytes(m.Stats.TotalFileSize-lastTotalFileSize), maybeIncomplete, ) if *backupsShowItemID { @@ -130,6 +132,10 @@ func runBackupsCommand(context *kingpin.ParseContext) error { } count++ } + + if m.IncompleteReason == "" || !*backupsIncludeIncomplete { + lastTotalFileSize = m.Stats.TotalFileSize + } } return nil @@ -153,7 +159,7 @@ func deltaBytes(b int64) string { return "(+" + units.BytesStringBase10(b) + ")" } - return "(no change)" + return "" } func init() { diff --git a/cli/command_expire.go b/cli/command_expire.go index f0039ca94..6d5a66e67 100644 --- a/cli/command_expire.go +++ b/cli/command_expire.go @@ -68,6 +68,10 @@ func expireSnapshotsForSingleSource(snapshots []*snapshot.Manifest, pol *snapsho } } + if s.IncompleteReason != "" { + continue + } + if pol.Expiration.KeepLatest != nil { registerSnapshot(fmt.Sprintf("%v", i), "latest", *pol.Expiration.KeepLatest) }