Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add an updated flag to backup details (#1813)
Browse files Browse the repository at this point in the history
## Description

Adds a flag in backup details that indicates whether the item in that backup is new/updated.

Currently always set to `true` but once we implement #1800 - we will set this to false for existing items from
base snapshots.

## Does this PR need a docs update or release note?

- [ ] ✅ Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x] ⛔ No 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #1812 

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x] ⚡ Unit test
- [ ] 💚 E2E
  • Loading branch information
vkamra authored Dec 15, 2022
1 parent 0b5bf1b commit debe74a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/internal/connector/exchange/service_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ func restoreCollection(
itemPath.String(),
itemPath.ShortRef(),
"",
true,
details.ItemInfo{
Exchange: info,
})
Expand Down
1 change: 1 addition & 0 deletions src/internal/connector/onedrive/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func RestoreCollection(
itemPath.String(),
itemPath.ShortRef(),
"",
true,
itemInfo)

metrics.Successes++
Expand Down
1 change: 1 addition & 0 deletions src/internal/kopia/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func (cp *corsoProgress) FinishedFile(relativePath string, err error) {
d.repoPath.String(),
d.repoPath.ShortRef(),
parent.ShortRef(),
true,
d.info,
)

Expand Down
3 changes: 2 additions & 1 deletion src/internal/streamstore/streamstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (suite *StreamStoreIntegrationSuite) TestDetails() {

deets := &details.Details{}

deets.Add("ref", "shortref", "parentref",
deets.Add("ref", "shortref", "parentref", true,
details.ItemInfo{
Exchange: &details.ExchangeInfo{
Subject: "hello world",
Expand All @@ -69,6 +69,7 @@ func (suite *StreamStoreIntegrationSuite) TestDetails() {
assert.Equal(t, deets.Entries[0].ParentRef, readDeets.Entries[0].ParentRef)
assert.Equal(t, deets.Entries[0].ShortRef, readDeets.Entries[0].ShortRef)
assert.Equal(t, deets.Entries[0].RepoRef, readDeets.Entries[0].RepoRef)
assert.Equal(t, deets.Entries[0].Updated, readDeets.Entries[0].Updated)
assert.NotNil(t, readDeets.Entries[0].Exchange)
assert.Equal(t, *deets.Entries[0].Exchange, *readDeets.Entries[0].Exchange)
}
6 changes: 5 additions & 1 deletion src/pkg/backup/details/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,14 @@ type Details struct {
knownFolders map[string]struct{} `json:"-"`
}

func (d *Details) Add(repoRef, shortRef, parentRef string, info ItemInfo) {
func (d *Details) Add(repoRef, shortRef, parentRef string, updated bool, info ItemInfo) {
d.mu.Lock()
defer d.mu.Unlock()
d.Entries = append(d.Entries, DetailsEntry{
RepoRef: repoRef,
ShortRef: shortRef,
ParentRef: parentRef,
Updated: updated,
ItemInfo: info,
})
}
Expand Down Expand Up @@ -163,6 +164,9 @@ type DetailsEntry struct {
RepoRef string `json:"repoRef"`
ShortRef string `json:"shortRef"`
ParentRef string `json:"parentRef,omitempty"`
// Indicates the item was added or updated in this backup
// Always `true` for full backups
Updated bool `json:"updated"`
ItemInfo
}

Expand Down

0 comments on commit debe74a

Please sign in to comment.