Fix NPE in SharePoint incremental backup (#3307)
Original code was switching based on the ItemType, but SharePoint historically used the OneDriveItem ItemType, making the system think it should be updating a OneDriveItemInfo struct instead of a SharePointItemInfo struct. Also add a regression test for older backup formats. --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) * closes #3306 #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
288e446672
commit
67d5c53420
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased] (beta)
|
## [Unreleased] (beta)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix nil pointer exception when running an incremental backup on SharePoint where the base backup used an older index data format.
|
||||||
|
|
||||||
## [v0.7.0] (beta) - 2023-05-02
|
## [v0.7.0] (beta) - 2023-05-02
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -628,14 +628,21 @@ func UpdateItem(item *ItemInfo, newLocPath *path.Builder) {
|
|||||||
// contained in them.
|
// contained in them.
|
||||||
var updatePath func(newLocPath *path.Builder)
|
var updatePath func(newLocPath *path.Builder)
|
||||||
|
|
||||||
switch item.infoType() {
|
// Can't switch based on infoType because that's been unstable.
|
||||||
case ExchangeContact, ExchangeEvent, ExchangeMail:
|
if item.Exchange != nil {
|
||||||
updatePath = item.Exchange.UpdateParentPath
|
updatePath = item.Exchange.UpdateParentPath
|
||||||
case SharePointLibrary:
|
} else if item.SharePoint != nil {
|
||||||
|
// SharePoint used to store library items with the OneDriveItem ItemType.
|
||||||
|
// Start switching them over as we see them since there's no point in
|
||||||
|
// keeping the old format.
|
||||||
|
if item.SharePoint.ItemType == OneDriveItem {
|
||||||
|
item.SharePoint.ItemType = SharePointLibrary
|
||||||
|
}
|
||||||
|
|
||||||
updatePath = item.SharePoint.UpdateParentPath
|
updatePath = item.SharePoint.UpdateParentPath
|
||||||
case OneDriveItem:
|
} else if item.OneDrive != nil {
|
||||||
updatePath = item.OneDrive.UpdateParentPath
|
updatePath = item.OneDrive.UpdateParentPath
|
||||||
default:
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1148,6 +1148,28 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "SharePoint Old Format",
|
||||||
|
input: ItemInfo{
|
||||||
|
SharePoint: &SharePointInfo{
|
||||||
|
ItemType: OneDriveItem,
|
||||||
|
ParentPath: folder1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
locPath: newOneDrivePB,
|
||||||
|
expectedItem: ItemInfo{
|
||||||
|
SharePoint: &SharePointInfo{
|
||||||
|
ItemType: SharePointLibrary,
|
||||||
|
ParentPath: folder2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Empty Item Doesn't Fail",
|
||||||
|
input: ItemInfo{},
|
||||||
|
locPath: newOneDrivePB,
|
||||||
|
expectedItem: ItemInfo{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user