From ecb894fc17133eeccfe552b0192bf279bb8e8277 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Mon, 6 Jun 2022 10:12:18 -0700 Subject: [PATCH] Struct with information about completed uploads (#121) POD struct that holds some simple information about a kopia upload. Not wrapping or returning a handle to a kopia struct to keep upper layers of corso clear of type dependencies. Struct will help with tests as it can be returned from public functions in the KopiaWrapper package allowing more black-box testing. Especially useful since we don't yet have a restore flow, which means we can't test data == restore(backup(data)). --- src/internal/kopia/kopia.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/internal/kopia/kopia.go b/src/internal/kopia/kopia.go index 78e4a924f..e162808ac 100644 --- a/src/internal/kopia/kopia.go +++ b/src/internal/kopia/kopia.go @@ -5,6 +5,7 @@ import ( "github.com/kopia/kopia/repo" "github.com/kopia/kopia/repo/blob" + "github.com/kopia/kopia/snapshot" "github.com/pkg/errors" "github.com/alcionai/corso/pkg/storage" @@ -19,6 +20,26 @@ var ( errConnect = errors.New("connecting repo") ) +type BackupStats struct { + TotalFileCount int + TotalDirectoryCount int + IgnoredErrorCount int + ErrorCount int + Incomplete bool + IncompleteReason string +} + +func manifestToStats(man *snapshot.Manifest) BackupStats { + return BackupStats{ + TotalFileCount: int(man.Stats.TotalFileCount), + TotalDirectoryCount: int(man.Stats.TotalDirectoryCount), + IgnoredErrorCount: int(man.Stats.IgnoredErrorCount), + ErrorCount: int(man.Stats.ErrorCount), + Incomplete: man.IncompleteReason == "", + IncompleteReason: man.IncompleteReason, + } +} + type KopiaWrapper struct { storage storage.Storage rep repo.Repository