Compare commits
6 Commits
ce0d7b45a1
...
706284d590
| Author | SHA1 | Date | |
|---|---|---|---|
| 706284d590 | |||
| 75564a504e | |||
| edd3e5fdb2 | |||
| d5796bd6c1 | |||
| 90e855ef99 | |||
| 2185421c01 |
@@ -407,6 +407,7 @@ Message classes:
|
|||||||
| Warning | `⚠️ Warning:` (orange/yellow) | column 0 | Recoverable problem |
|
| Warning | `⚠️ Warning:` (orange/yellow) | column 0 | Recoverable problem |
|
||||||
| Error | `🛑 ERROR:` (red) | column 0 | Operation aborted |
|
| Error | `🛑 ERROR:` (red) | column 0 | Operation aborted |
|
||||||
| Progress | ` 》` (white) | column 2 | Heartbeat or per-item status during a long-running operation |
|
| Progress | ` 》` (white) | column 2 | Heartbeat or per-item status during a long-running operation |
|
||||||
|
| Detail | ` 》` (white) | column 2 | Continuation/sub-line of a preceding Complete (visually identical to Progress) |
|
||||||
|
|
||||||
Conventions:
|
Conventions:
|
||||||
|
|
||||||
@@ -421,12 +422,13 @@ Conventions:
|
|||||||
"Uploaded" for Complete. Never write the words "begin" or "complete"
|
"Uploaded" for Complete. Never write the words "begin" or "complete"
|
||||||
in the body — the marker color already conveys that.
|
in the body — the marker color already conveys that.
|
||||||
* All elapsed and remaining-time fields are explicitly scoped to their
|
* All elapsed and remaining-time fields are explicitly scoped to their
|
||||||
subject: write "blob upload elapsed 30s, blob upload estimated remaining
|
subject: write "blob upload elapsed: 30s, blob upload ETA: 03:15:00
|
||||||
time (14s), finish at 2026-06-17T03:15:00Z", never just "elapsed 30s,
|
(est remain 14s)", never just "elapsed 30s, ETA 14s".
|
||||||
ETA 14s".
|
|
||||||
* "ETA" means an absolute clock time (when the operation will finish),
|
* "ETA" means an absolute clock time (when the operation will finish),
|
||||||
not a remaining-duration. Use `ui.Time()` for the former and
|
not a remaining-duration. Use `ui.Time()` for the former and
|
||||||
`ui.Duration()` for the latter, and label both.
|
`ui.Duration()` for the latter, and label both.
|
||||||
|
* `ui.Time` formats same-day times as `HH:MM:SS` and other-day times as
|
||||||
|
`YYYY-MM-DD HH:MM:SS`. No timezone — local time is implied.
|
||||||
|
|
||||||
Value colorizers in `internal/ui` colorize specific value types
|
Value colorizers in `internal/ui` colorize specific value types
|
||||||
consistently. Compose messages from these helpers rather than embedding
|
consistently. Compose messages from these helpers rather than embedding
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func setupGlobals(lc fx.Lifecycle, g *globals.Globals, v *vaultik.Vaultik, opts
|
|||||||
g.ShortCommit(), g.CommitDate,
|
g.ShortCommit(), g.CommitDate,
|
||||||
g.StartTime.Format(time.RFC3339))
|
g.StartTime.Format(time.RFC3339))
|
||||||
v.UI.Banner("%s", globals.Homepage)
|
v.UI.Banner("%s", globals.Homepage)
|
||||||
|
v.UI.Banner("")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -777,16 +777,16 @@ func (s *Scanner) printScanProgressLine(filesScanned int64, changedCount int, es
|
|||||||
eta = time.Duration(float64(remaining)/rate) * time.Second
|
eta = time.Duration(float64(remaining)/rate) * time.Second
|
||||||
}
|
}
|
||||||
if eta > 0 {
|
if eta > 0 {
|
||||||
s.ui.Progress("Snapshot source files enumeration: %s files (~%s), %s changed or new, %.0f files/sec, enumeration elapsed %s, enumeration estimated remaining time (%s), finish at %s.",
|
s.ui.Progress("Snapshot source files enumeration: %s files (~%s), %s changed or new, %.0f files/sec, enumeration elapsed: %s, enumeration ETA: %s (est remain %s).",
|
||||||
s.ui.Count(int(filesScanned)),
|
s.ui.Count(int(filesScanned)),
|
||||||
s.ui.Percent(pct),
|
s.ui.Percent(pct),
|
||||||
s.ui.Count(changedCount),
|
s.ui.Count(changedCount),
|
||||||
rate,
|
rate,
|
||||||
s.ui.Duration(elapsed),
|
s.ui.Duration(elapsed),
|
||||||
s.ui.Duration(eta),
|
s.ui.Time(time.Now().Add(eta)),
|
||||||
s.ui.Time(time.Now().Add(eta)))
|
s.ui.Duration(eta))
|
||||||
} else {
|
} else {
|
||||||
s.ui.Progress("Snapshot source files enumeration: %s files (~%s), %s changed or new, %.0f files/sec, enumeration elapsed %s.",
|
s.ui.Progress("Snapshot source files enumeration: %s files (~%s), %s changed or new, %.0f files/sec, enumeration elapsed: %s.",
|
||||||
s.ui.Count(int(filesScanned)),
|
s.ui.Count(int(filesScanned)),
|
||||||
s.ui.Percent(pct),
|
s.ui.Percent(pct),
|
||||||
s.ui.Count(changedCount),
|
s.ui.Count(changedCount),
|
||||||
@@ -794,7 +794,7 @@ func (s *Scanner) printScanProgressLine(filesScanned int64, changedCount int, es
|
|||||||
s.ui.Duration(elapsed))
|
s.ui.Duration(elapsed))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.ui.Progress("Snapshot source files enumeration: %s files seen, %s changed or new, %.0f files/sec, enumeration elapsed %s.",
|
s.ui.Progress("Snapshot source files enumeration: %s files seen, %s changed or new, %.0f files/sec, enumeration elapsed: %s.",
|
||||||
s.ui.Count(int(filesScanned)),
|
s.ui.Count(int(filesScanned)),
|
||||||
s.ui.Count(changedCount),
|
s.ui.Count(changedCount),
|
||||||
rate,
|
rate,
|
||||||
@@ -1067,7 +1067,7 @@ func (s *Scanner) printProcessingProgress(filesProcessed, totalFiles int, bytesP
|
|||||||
}
|
}
|
||||||
|
|
||||||
if eta > 0 {
|
if eta > 0 {
|
||||||
s.ui.Progress("Snapshot file processing: %s/%s files (%s), %s/%s, %s, %.0f files/sec, processing elapsed %s, processing estimated remaining time (%s), finish at %s.",
|
s.ui.Progress("Snapshot file processing: %s/%s files (%s), %s/%s, %s, %.0f files/sec, processing elapsed: %s, processing ETA: %s (est remain %s).",
|
||||||
s.ui.Count(filesProcessed),
|
s.ui.Count(filesProcessed),
|
||||||
s.ui.Count(totalFiles),
|
s.ui.Count(totalFiles),
|
||||||
s.ui.Percent(pct),
|
s.ui.Percent(pct),
|
||||||
@@ -1076,10 +1076,10 @@ func (s *Scanner) printProcessingProgress(filesProcessed, totalFiles int, bytesP
|
|||||||
s.ui.Speed(byteRate),
|
s.ui.Speed(byteRate),
|
||||||
fileRate,
|
fileRate,
|
||||||
s.ui.Duration(elapsed),
|
s.ui.Duration(elapsed),
|
||||||
s.ui.Duration(eta),
|
s.ui.Time(time.Now().Add(eta)),
|
||||||
s.ui.Time(time.Now().Add(eta)))
|
s.ui.Duration(eta))
|
||||||
} else {
|
} else {
|
||||||
s.ui.Progress("Snapshot file processing: %s/%s files (%s), %s/%s, %s, %.0f files/sec, processing elapsed %s.",
|
s.ui.Progress("Snapshot file processing: %s/%s files (%s), %s/%s, %s, %.0f files/sec, processing elapsed: %s.",
|
||||||
s.ui.Count(filesProcessed),
|
s.ui.Count(filesProcessed),
|
||||||
s.ui.Count(totalFiles),
|
s.ui.Count(totalFiles),
|
||||||
s.ui.Percent(pct),
|
s.ui.Percent(pct),
|
||||||
@@ -1251,15 +1251,15 @@ func (s *Scanner) makeUploadProgressCallback(ctx context.Context, finishedBlob *
|
|||||||
if avgSpeed > 0 {
|
if avgSpeed > 0 {
|
||||||
eta = time.Duration(float64(finishedBlob.Compressed-uploaded)/avgSpeed) * time.Second
|
eta = time.Duration(float64(finishedBlob.Compressed-uploaded)/avgSpeed) * time.Second
|
||||||
}
|
}
|
||||||
s.ui.Progress("Blob upload %s: %s / %s (%s) at %s, blob upload elapsed %s, blob upload estimated remaining time (%s), finish at %s.",
|
s.ui.Progress("Blob upload %s: %s / %s (%s) at %s, blob upload elapsed: %s, blob upload ETA: %s (est remain %s).",
|
||||||
s.ui.Hex(finishedBlob.Hash),
|
s.ui.Hex(finishedBlob.Hash),
|
||||||
s.ui.Size(uploaded),
|
s.ui.Size(uploaded),
|
||||||
s.ui.Size(finishedBlob.Compressed),
|
s.ui.Size(finishedBlob.Compressed),
|
||||||
s.ui.Percent(pct),
|
s.ui.Percent(pct),
|
||||||
s.ui.Speed(avgSpeed),
|
s.ui.Speed(avgSpeed),
|
||||||
s.ui.Duration(totalElapsed),
|
s.ui.Duration(totalElapsed),
|
||||||
s.ui.Duration(eta),
|
s.ui.Time(now.Add(eta)),
|
||||||
s.ui.Time(now.Add(eta)))
|
s.ui.Duration(eta))
|
||||||
lastStdoutTime = now
|
lastStdoutTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,14 @@ const (
|
|||||||
const Marker = "》"
|
const Marker = "》"
|
||||||
|
|
||||||
// Writer formats and emits user-facing messages with optional ANSI color.
|
// Writer formats and emits user-facing messages with optional ANSI color.
|
||||||
|
// It also counts warnings and errors emitted so the caller can summarize at
|
||||||
|
// the end of an operation ("Finished successfully." vs "Finished with
|
||||||
|
// warnings.").
|
||||||
type Writer struct {
|
type Writer struct {
|
||||||
out io.Writer
|
out io.Writer
|
||||||
color bool
|
color bool
|
||||||
|
warnings int
|
||||||
|
errors int
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a Writer that emits to out. Color is enabled when out is a
|
// New returns a Writer that emits to out. Color is enabled when out is a
|
||||||
@@ -115,6 +120,7 @@ func (w *Writer) Notice(format string, args ...any) {
|
|||||||
|
|
||||||
// Warning prints "⚠️ Warning: " in orange/yellow followed by the message.
|
// Warning prints "⚠️ Warning: " in orange/yellow followed by the message.
|
||||||
func (w *Writer) Warning(format string, args ...any) {
|
func (w *Writer) Warning(format string, args ...any) {
|
||||||
|
w.warnings++
|
||||||
prefix := "⚠️ " + w.paint(ansiYellow+ansiBold, "Warning: ")
|
prefix := "⚠️ " + w.paint(ansiYellow+ansiBold, "Warning: ")
|
||||||
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
@@ -123,19 +129,38 @@ func (w *Writer) Warning(format string, args ...any) {
|
|||||||
// same writer as everything else; callers that want stderr should
|
// same writer as everything else; callers that want stderr should
|
||||||
// construct a separate Writer for it.
|
// construct a separate Writer for it.
|
||||||
func (w *Writer) Error(format string, args ...any) {
|
func (w *Writer) Error(format string, args ...any) {
|
||||||
|
w.errors++
|
||||||
prefix := "🛑 " + w.paint(ansiRed+ansiBold, "ERROR: ")
|
prefix := "🛑 " + w.paint(ansiRed+ansiBold, "ERROR: ")
|
||||||
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
_, _ = fmt.Fprintln(w.out, prefix+fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detail prints an indented continuation line under a preceding Complete
|
||||||
|
// (or other top-level message). Marker " 》" (white) at column 2.
|
||||||
|
// Distinct from Progress (semantically a "heartbeat") in usage but
|
||||||
|
// visually identical.
|
||||||
|
func (w *Writer) Detail(format string, args ...any) {
|
||||||
|
w.emit(ansiWhite, " "+Marker, "", format, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WarningCount returns the number of Warning() calls this writer has emitted.
|
||||||
|
func (w *Writer) WarningCount() int { return w.warnings }
|
||||||
|
|
||||||
|
// ErrorCount returns the number of Error() calls this writer has emitted.
|
||||||
|
func (w *Writer) ErrorCount() int { return w.errors }
|
||||||
|
|
||||||
// Progress prints an indented heartbeat / per-item update, marker in white.
|
// Progress prints an indented heartbeat / per-item update, marker in white.
|
||||||
func (w *Writer) Progress(format string, args ...any) {
|
func (w *Writer) Progress(format string, args ...any) {
|
||||||
w.emit(ansiWhite, " "+Marker, "", format, args)
|
w.emit(ansiWhite, " "+Marker, "", format, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Banner prints a line with no marker, left-aligned. Used for the
|
// Banner prints a line with no marker, left-aligned. Bold when color
|
||||||
// application startup banner only.
|
// is enabled. Used for the application startup banner only.
|
||||||
func (w *Writer) Banner(format string, args ...any) {
|
func (w *Writer) Banner(format string, args ...any) {
|
||||||
_, _ = fmt.Fprintln(w.out, fmt.Sprintf(format, args...))
|
body := fmt.Sprintf(format, args...)
|
||||||
|
if w.color {
|
||||||
|
body = ansiBold + body + ansiReset
|
||||||
|
}
|
||||||
|
_, _ = fmt.Fprintln(w.out, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit writes "<prefix> <body>\n" with the prefix painted in prefixColor
|
// emit writes "<prefix> <body>\n" with the prefix painted in prefixColor
|
||||||
@@ -188,9 +213,17 @@ func (w *Writer) Duration(d time.Duration) string {
|
|||||||
return w.paint(ansiYellow, d.Round(time.Second).String())
|
return w.paint(ansiYellow, d.Round(time.Second).String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time colorizes an absolute time (RFC3339, second precision).
|
// Time colorizes an absolute clock time. If t falls on today's local
|
||||||
|
// calendar date the output is "HH:MM:SS"; otherwise it is
|
||||||
|
// "YYYY-MM-DD HH:MM:SS". No timezone is included — values are
|
||||||
|
// displayed in the process's local zone.
|
||||||
func (w *Writer) Time(t time.Time) string {
|
func (w *Writer) Time(t time.Time) string {
|
||||||
return w.paint(ansiYellow, t.Format(time.RFC3339))
|
t = t.Local()
|
||||||
|
now := time.Now()
|
||||||
|
if t.Year() == now.Year() && t.YearDay() == now.YearDay() {
|
||||||
|
return w.paint(ansiYellow, t.Format("15:04:05"))
|
||||||
|
}
|
||||||
|
return w.paint(ansiYellow, t.Format("2006-01-02 15:04:05"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count colorizes an integer count with thousands separators.
|
// Count colorizes an integer count with thousands separators.
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ func TestMessageMethodsPlain(t *testing.T) {
|
|||||||
{"Warning", func(w *Writer) { w.Warning("oops") }, "⚠️ Warning: oops\n"},
|
{"Warning", func(w *Writer) { w.Warning("oops") }, "⚠️ Warning: oops\n"},
|
||||||
{"Error", func(w *Writer) { w.Error("boom") }, "🛑 ERROR: boom\n"},
|
{"Error", func(w *Writer) { w.Error("boom") }, "🛑 ERROR: boom\n"},
|
||||||
{"Progress", func(w *Writer) { w.Progress("p") }, " 》 p\n"},
|
{"Progress", func(w *Writer) { w.Progress("p") }, " 》 p\n"},
|
||||||
{"Banner", func(w *Writer) { w.Banner("hello") }, "hello\n"},
|
{"Detail", func(w *Writer) { w.Detail("d") }, " 》 d\n"},
|
||||||
|
{"Banner", func(w *Writer) { w.Banner("hello") }, "hello\n"}, // plain mode, no bold
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@@ -39,6 +40,23 @@ func TestMessageMethodsPlain(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWarningErrorCounters(t *testing.T) {
|
||||||
|
w, _ := newTestWriter(false)
|
||||||
|
if w.WarningCount() != 0 || w.ErrorCount() != 0 {
|
||||||
|
t.Fatalf("expected fresh writer to have zero counts")
|
||||||
|
}
|
||||||
|
w.Info("normal")
|
||||||
|
w.Warning("first warn")
|
||||||
|
w.Warning("second warn")
|
||||||
|
w.Error("only error")
|
||||||
|
if got, want := w.WarningCount(), 2; got != want {
|
||||||
|
t.Errorf("WarningCount: got %d, want %d", got, want)
|
||||||
|
}
|
||||||
|
if got, want := w.ErrorCount(), 1; got != want {
|
||||||
|
t.Errorf("ErrorCount: got %d, want %d", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestColorOutputContainsANSI(t *testing.T) {
|
func TestColorOutputContainsANSI(t *testing.T) {
|
||||||
w, buf := newTestWriter(true)
|
w, buf := newTestWriter(true)
|
||||||
w.Error("boom")
|
w.Error("boom")
|
||||||
@@ -51,6 +69,15 @@ func TestColorOutputContainsANSI(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBannerBoldWhenColor(t *testing.T) {
|
||||||
|
w, buf := newTestWriter(true)
|
||||||
|
w.Banner("hello")
|
||||||
|
out := buf.String()
|
||||||
|
if !strings.Contains(out, "\033[1m") {
|
||||||
|
t.Errorf("expected bold ANSI escape in colored Banner output, got %q", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestValueFormattersPlain(t *testing.T) {
|
func TestValueFormattersPlain(t *testing.T) {
|
||||||
w, _ := newTestWriter(false)
|
w, _ := newTestWriter(false)
|
||||||
|
|
||||||
@@ -72,6 +99,16 @@ func TestValueFormattersPlain(t *testing.T) {
|
|||||||
if got := w.Percent(12.34); got != "12.3%" {
|
if got := w.Percent(12.34); got != "12.3%" {
|
||||||
t.Errorf("Percent: got %q", got)
|
t.Errorf("Percent: got %q", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time format: today → HH:MM:SS, other day → YYYY-MM-DD HH:MM:SS.
|
||||||
|
today := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 14, 30, 45, 0, time.Local)
|
||||||
|
if got := w.Time(today); got != "14:30:45" {
|
||||||
|
t.Errorf("Time today: got %q, want 14:30:45", got)
|
||||||
|
}
|
||||||
|
other := time.Date(2030, 1, 2, 3, 4, 5, 0, time.Local)
|
||||||
|
if got := w.Time(other); got != "2030-01-02 03:04:05" {
|
||||||
|
t.Errorf("Time other day: got %q", got)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValueFormattersColored(t *testing.T) {
|
func TestValueFormattersColored(t *testing.T) {
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ func (v *Vaultik) CreateSnapshot(opts *SnapshotCreateOptions) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v.UI.WarningCount() > 0 {
|
||||||
|
v.UI.Complete("Finished (with %d warnings).", v.UI.WarningCount())
|
||||||
|
} else {
|
||||||
|
v.UI.Complete("Finished successfully.")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,35 +342,35 @@ func (v *Vaultik) printSnapshotSummary(snapshotID string, startTime time.Time, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
v.UI.Complete("Created snapshot %s.", v.UI.Snapshot(snapshotID))
|
v.UI.Complete("Created snapshot %s.", v.UI.Snapshot(snapshotID))
|
||||||
filesMsg := fmt.Sprintf("Files: %s examined, %s to process, %s unchanged",
|
filesMsg := fmt.Sprintf("Files: %s examined, %s processed, %s unchanged",
|
||||||
v.UI.Count(stats.totalFiles),
|
v.UI.Count(stats.totalFiles),
|
||||||
v.UI.Count(totalFilesChanged),
|
v.UI.Count(totalFilesChanged),
|
||||||
v.UI.Count(stats.totalFilesSkipped))
|
v.UI.Count(stats.totalFilesSkipped))
|
||||||
if stats.totalFilesDeleted > 0 {
|
if stats.totalFilesDeleted > 0 {
|
||||||
filesMsg += fmt.Sprintf(", %s deleted", v.UI.Count(stats.totalFilesDeleted))
|
filesMsg += fmt.Sprintf(", %s deleted", v.UI.Count(stats.totalFilesDeleted))
|
||||||
}
|
}
|
||||||
v.UI.Info("%s.", filesMsg)
|
v.UI.Detail("%s.", filesMsg)
|
||||||
|
|
||||||
dataMsg := fmt.Sprintf("Data: %s total (%s to process)",
|
dataMsg := fmt.Sprintf("Data: %s total (%s processed)",
|
||||||
v.UI.Size(totalBytesAll),
|
v.UI.Size(totalBytesAll),
|
||||||
v.UI.Size(stats.totalBytes))
|
v.UI.Size(stats.totalBytes))
|
||||||
if stats.totalBytesDeleted > 0 {
|
if stats.totalBytesDeleted > 0 {
|
||||||
dataMsg += fmt.Sprintf(", %s deleted", v.UI.Size(stats.totalBytesDeleted))
|
dataMsg += fmt.Sprintf(", %s deleted", v.UI.Size(stats.totalBytesDeleted))
|
||||||
}
|
}
|
||||||
v.UI.Info("%s.", dataMsg)
|
v.UI.Detail("%s.", dataMsg)
|
||||||
|
|
||||||
if stats.totalBlobsUploaded > 0 {
|
if stats.totalBlobsUploaded > 0 {
|
||||||
v.UI.Info("Storage: %s compressed from %s (%.2fx ratio).",
|
v.UI.Detail("Storage: %s compressed from %s (%.2fx ratio).",
|
||||||
v.UI.Size(totalBlobSizeCompressed),
|
v.UI.Size(totalBlobSizeCompressed),
|
||||||
v.UI.Size(totalBlobSizeUncompressed),
|
v.UI.Size(totalBlobSizeUncompressed),
|
||||||
compressionRatio)
|
compressionRatio)
|
||||||
v.UI.Info("Upload: %d blobs, %s in %s (%s).",
|
v.UI.Detail("Upload: %d blobs, %s in %s (%s).",
|
||||||
stats.totalBlobsUploaded,
|
stats.totalBlobsUploaded,
|
||||||
v.UI.Size(stats.totalBytesUploaded),
|
v.UI.Size(stats.totalBytesUploaded),
|
||||||
v.UI.Duration(stats.uploadDuration),
|
v.UI.Duration(stats.uploadDuration),
|
||||||
formatUploadSpeed(stats.totalBytesUploaded, stats.uploadDuration))
|
formatUploadSpeed(stats.totalBytesUploaded, stats.uploadDuration))
|
||||||
}
|
}
|
||||||
v.UI.Info("Snapshot create duration: %s.", v.UI.Duration(snapshotDuration))
|
v.UI.Detail("Snapshot create duration: %s.", v.UI.Duration(snapshotDuration))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getSnapshotBlobSizes returns total compressed and uncompressed blob sizes for a snapshot
|
// getSnapshotBlobSizes returns total compressed and uncompressed blob sizes for a snapshot
|
||||||
@@ -1277,6 +1283,9 @@ func (v *Vaultik) PruneDatabase() (*PruneResult, error) {
|
|||||||
|
|
||||||
result := &PruneResult{}
|
result := &PruneResult{}
|
||||||
|
|
||||||
|
// Snapshot counts before deletion of incompletes.
|
||||||
|
snapshotCountBefore, _ := v.getTableCount("snapshots")
|
||||||
|
|
||||||
// First, delete any incomplete snapshots
|
// First, delete any incomplete snapshots
|
||||||
incompleteSnapshots, err := v.Repositories.Snapshots.GetIncompleteSnapshots(v.ctx)
|
incompleteSnapshots, err := v.Repositories.Snapshots.GetIncompleteSnapshots(v.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1329,8 +1338,12 @@ func (v *Vaultik) PruneDatabase() (*PruneResult, error) {
|
|||||||
"orphaned_blobs", result.BlobsDeleted,
|
"orphaned_blobs", result.BlobsDeleted,
|
||||||
)
|
)
|
||||||
|
|
||||||
v.UI.Complete("Pruned local index database: %d incomplete snapshots, %d orphaned files, %d orphaned chunks, %d orphaned blobs removed.",
|
snapshotCountAfter := snapshotCountBefore - result.SnapshotsDeleted
|
||||||
result.SnapshotsDeleted, result.FilesDeleted, result.ChunksDeleted, result.BlobsDeleted)
|
v.UI.Complete("Pruned local index database.")
|
||||||
|
v.UI.Detail("Incomplete snapshots: %d removed (%d remain).", result.SnapshotsDeleted, snapshotCountAfter)
|
||||||
|
v.UI.Detail("Orphaned files: %d removed (%d remain).", result.FilesDeleted, fileCountAfter)
|
||||||
|
v.UI.Detail("Orphaned chunks: %d removed (%d remain).", result.ChunksDeleted, chunkCountAfter)
|
||||||
|
v.UI.Detail("Orphaned blobs: %d removed (%d remain).", result.BlobsDeleted, blobCountAfter)
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user