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)).
This commit is contained in:
ashmrtn 2022-06-06 10:12:18 -07:00 committed by GitHub
parent f68a4e3f46
commit ecb894fc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"github.com/kopia/kopia/repo" "github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/blob" "github.com/kopia/kopia/repo/blob"
"github.com/kopia/kopia/snapshot"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/alcionai/corso/pkg/storage" "github.com/alcionai/corso/pkg/storage"
@ -19,6 +20,26 @@ var (
errConnect = errors.New("connecting repo") 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 { type KopiaWrapper struct {
storage storage.Storage storage storage.Storage
rep repo.Repository rep repo.Repository