From 7b926524b1a16a0686bd34ea94b8fe5a45a63c31 Mon Sep 17 00:00:00 2001 From: ryanfkeepers Date: Wed, 16 Aug 2023 11:06:22 -0600 Subject: [PATCH] setting aside --- src/internal/kopia/base_finder.go | 23 ++++++++++++++++------- src/internal/kopia/upload.go | 12 ++++++------ src/internal/operations/backup.go | 8 ++++---- src/pkg/backup/identity/identity.go | 8 ++++++++ 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/internal/kopia/base_finder.go b/src/internal/kopia/base_finder.go index 8e1ff79a5..88fddf0f3 100644 --- a/src/internal/kopia/base_finder.go +++ b/src/internal/kopia/base_finder.go @@ -30,6 +30,10 @@ const ( userTagPrefix = "tag:" ) +// --------------------------------------------------------------------------- +// reasoners +// --------------------------------------------------------------------------- + func NewReason( tenant, resource string, service path.ServiceType, @@ -47,10 +51,11 @@ type reason struct { // tenant appears here so that when this is moved to an inject package nothing // needs changed. However, kopia itself is blind to the fields in the reason // struct and relies on helper functions to get the information it needs. - tenant string - resource string - service path.ServiceType - category path.CategoryType + tenant string + serviceResources []path.ServiceResource + resource string + service path.ServiceType + category path.CategoryType } func (r reason) Tenant() string { @@ -94,6 +99,10 @@ func reasonKey(r identity.Reasoner) string { return r.ProtectedResource() + r.Service().String() + r.Category().String() } +// --------------------------------------------------------------------------- +// entries +// --------------------------------------------------------------------------- + type BackupEntry struct { *backup.Backup Reasons []identity.Reasoner @@ -108,7 +117,7 @@ type ManifestEntry struct { // 1. backup user1 email,contacts -> B1 // 2. backup user1 contacts -> B2 (uses B1 as base) // 3. backup user1 email,contacts,events (uses B1 for email, B2 for contacts) - Reasons []identity.Reasoner + Reasons []identity.SubtreeReasoner } func (me ManifestEntry) GetTag(key string) (string, bool) { @@ -284,7 +293,7 @@ func (b *baseFinder) findBasesInSet( } assistSnap := ManifestEntry{ Manifest: man, - Reasons: []identity.Reasoner{reason}, + Reasons: []identity.SubtreeReasoner{reason}, } assistBase = &backupBase{ @@ -310,7 +319,7 @@ func (b *baseFinder) findBasesInSet( mergeSnap := ManifestEntry{ Manifest: man, - Reasons: []identity.Reasoner{reason}, + Reasons: []identity.SubtreeReasoner{reason}, } mergeModel := BackupEntry{ diff --git a/src/internal/kopia/upload.go b/src/internal/kopia/upload.go index b10af64ba..a5a4be7e6 100644 --- a/src/internal/kopia/upload.go +++ b/src/internal/kopia/upload.go @@ -1070,20 +1070,20 @@ const ( func inflateBaseTree( ctx context.Context, loader snapshotLoader, - snap ManifestEntry, + snapshot ManifestEntry, updatedPaths map[string]path.Path, roots map[string]*treeMap, ) error { // Only complete snapshots should be used to source base information. // Snapshots for checkpoints will rely on kopia-assisted dedupe to efficiently // handle items that were completely uploaded before Corso crashed. - if len(snap.IncompleteReason) > 0 { + if len(snapshot.IncompleteReason) > 0 { return nil } - ctx = clues.Add(ctx, "snapshot_base_id", snap.ID) + ctx = clues.Add(ctx, "snapshot_base_id", snapshot.ID) - root, err := loader.SnapshotRoot(snap.Manifest) + root, err := loader.SnapshotRoot(snapshot.Manifest) if err != nil { return clues.Wrap(err, "getting snapshot root directory").WithClues(ctx) } @@ -1094,12 +1094,12 @@ func inflateBaseTree( } // Some logging to help track things. - logBaseInfo(ctx, snap) + logBaseInfo(ctx, snapshot) // For each subtree corresponding to the tuple // (resource owner, service, category) merge the directories in the base with // what has been reported in the collections we got. - for _, r := range snap.Reasons { + for _, r := range snapshot.Reasons { ictx := clues.Add( ctx, "subtree_service", r.Service().String(), diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 1a1046a92..bc9446dee 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -351,7 +351,7 @@ func (op *BackupOperation) do( return nil, clues.Stack(err) } - mans, mdColls, canUseMetadata, err := produceManifestsAndMetadata( + bases, mdColls, canUseMetadata, err := produceManifestsAndMetadata( ctx, kbf, op.kopia, @@ -366,7 +366,7 @@ func (op *BackupOperation) do( ctx = clues.Add(ctx, "can_use_metadata", canUseMetadata) if canUseMetadata { - lastBackupVersion = mans.MinBackupVersion() + lastBackupVersion = bases.MinBackupVersion() } // TODO(ashmrtn): This should probably just return a collection that deletes @@ -396,7 +396,7 @@ func (op *BackupOperation) do( op.kopia, op.account.ID(), reasons, - mans, + bases, cs, ssmb, backupID, @@ -413,7 +413,7 @@ func (op *BackupOperation) do( err = mergeDetails( ctx, detailsStore, - mans, + bases, toMerge, deets, writeStats, diff --git a/src/pkg/backup/identity/identity.go b/src/pkg/backup/identity/identity.go index 1eac0b0f9..c4ecb439d 100644 --- a/src/pkg/backup/identity/identity.go +++ b/src/pkg/backup/identity/identity.go @@ -2,6 +2,11 @@ package identity import "github.com/alcionai/corso/src/pkg/path" +type SubtreeReasoner interface { + Reasoner + SubtreePather +} + // Reasoner describes the parts of the backup that make up its // data identity: the tenant, protected resources, services, and // categories which are held within the backup. @@ -21,6 +26,9 @@ type Reasoner interface { // should only provide the first service; not a subservice. Service() path.ServiceType Category() path.CategoryType +} + +type SubtreePather interface { // SubtreePath returns the path prefix for data in existing backups that have // parameters (tenant, protected resourced, etc) that match this Reasoner. SubtreePath() (path.Path, error)