From 85b5877987221c09df196226a7536965716f2a3a Mon Sep 17 00:00:00 2001 From: Danny Date: Tue, 10 Jan 2023 13:56:38 -0500 Subject: [PATCH] Backup Details: Onedrive details expanded (#2085) ## Description Updates the amount of metadata available for OneDrive backups. This does not affect the way `OneDrive` information is displayed to the user. ## Does this PR need a docs update or release note? - [x] :no_entry: No ## Type of change - [x] :sunflower: Feature ## Issue(s) *closes #2074 ## Test Plan - [x] :zap: Unit test --- src/internal/connector/onedrive/item.go | 22 +++++++++++++++------- src/pkg/backup/details/details.go | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/internal/connector/onedrive/item.go b/src/internal/connector/onedrive/item.go index 186e7a6a3..7f377d2cd 100644 --- a/src/internal/connector/onedrive/item.go +++ b/src/internal/connector/onedrive/item.go @@ -94,7 +94,7 @@ func driveItemReader( // doesn't have its size value updated as a side effect of creation, // and kiota drops any SetSize update. func oneDriveItemInfo(di models.DriveItemable, itemSize int64) *details.OneDriveInfo { - email := "" + var email, parent string if di.GetCreatedBy().GetUser() != nil { // User is sometimes not available when created via some @@ -105,13 +105,21 @@ func oneDriveItemInfo(di models.DriveItemable, itemSize int64) *details.OneDrive } } + if di.GetParentReference() != nil { + if di.GetParentReference().GetName() != nil { + // EndPoint is not always populated from external apps + parent = *di.GetParentReference().GetName() + } + } + return &details.OneDriveInfo{ - ItemType: details.OneDriveItem, - ItemName: *di.GetName(), - Created: *di.GetCreatedDateTime(), - Modified: *di.GetLastModifiedDateTime(), - Size: itemSize, - Owner: email, + ItemType: details.OneDriveItem, + ItemName: *di.GetName(), + Created: *di.GetCreatedDateTime(), + Modified: *di.GetLastModifiedDateTime(), + DriveName: parent, + Size: itemSize, + Owner: email, } } diff --git a/src/pkg/backup/details/details.go b/src/pkg/backup/details/details.go index 27075ec72..798c12ce2 100644 --- a/src/pkg/backup/details/details.go +++ b/src/pkg/backup/details/details.go @@ -520,6 +520,7 @@ func (i *SharePointInfo) UpdateParentPath(newPath path.Path) error { type OneDriveInfo struct { Created time.Time `json:"created,omitempty"` ItemName string `json:"itemName"` + DriveName string `json:"driveName"` ItemType ItemType `json:"itemType,omitempty"` Modified time.Time `json:"modified,omitempty"` Owner string `json:"owner,omitempty"`