Use custom drive items during backup
This commit is contained in:
parent
488c3458c9
commit
1d971fb2ef
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -52,7 +53,7 @@ type Collection struct {
|
|||||||
// represents
|
// represents
|
||||||
folderPath path.Path
|
folderPath path.Path
|
||||||
// M365 IDs of file items within this collection
|
// M365 IDs of file items within this collection
|
||||||
driveItems map[string]models.DriveItemable
|
driveItems map[string]custom.LiteDriveItemable
|
||||||
|
|
||||||
// Primary M365 ID of the drive this collection was created from
|
// Primary M365 ID of the drive this collection was created from
|
||||||
driveID string
|
driveID string
|
||||||
@ -172,7 +173,7 @@ func newColl(
|
|||||||
protectedResource: resource,
|
protectedResource: resource,
|
||||||
folderPath: currPath,
|
folderPath: currPath,
|
||||||
prevPath: prevPath,
|
prevPath: prevPath,
|
||||||
driveItems: map[string]models.DriveItemable{},
|
driveItems: map[string]custom.LiteDriveItemable{},
|
||||||
driveID: driveID,
|
driveID: driveID,
|
||||||
data: dataCh,
|
data: dataCh,
|
||||||
statusUpdater: statusUpdater,
|
statusUpdater: statusUpdater,
|
||||||
@ -191,8 +192,10 @@ func newColl(
|
|||||||
// populated. The return values denotes if the item was previously
|
// populated. The return values denotes if the item was previously
|
||||||
// present or is new one.
|
// present or is new one.
|
||||||
func (oc *Collection) Add(item models.DriveItemable) bool {
|
func (oc *Collection) Add(item models.DriveItemable) bool {
|
||||||
_, found := oc.driveItems[ptr.Val(item.GetId())]
|
liteItem := custom.ToLiteDriveItemable(item)
|
||||||
oc.driveItems[ptr.Val(item.GetId())] = item
|
|
||||||
|
_, found := oc.driveItems[ptr.Val(liteItem.GetId())]
|
||||||
|
oc.driveItems[ptr.Val(liteItem.GetId())] = liteItem
|
||||||
|
|
||||||
// if !found, it's a new addition
|
// if !found, it's a new addition
|
||||||
return !found
|
return !found
|
||||||
@ -277,7 +280,7 @@ func (oc Collection) DoNotMergeItems() bool {
|
|||||||
func (oc *Collection) getDriveItemContent(
|
func (oc *Collection) getDriveItemContent(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
driveID string,
|
driveID string,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
) (io.ReadCloser, error) {
|
) (io.ReadCloser, error) {
|
||||||
var (
|
var (
|
||||||
@ -360,7 +363,7 @@ func downloadContent(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
iaag itemAndAPIGetter,
|
iaag itemAndAPIGetter,
|
||||||
uc getItemPropertyer,
|
uc getItemPropertyer,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
driveID string,
|
driveID string,
|
||||||
counter *count.Bus,
|
counter *count.Bus,
|
||||||
) (io.ReadCloser, error) {
|
) (io.ReadCloser, error) {
|
||||||
@ -395,7 +398,9 @@ func downloadContent(
|
|||||||
return nil, clues.Wrap(err, "retrieving expired item")
|
return nil, clues.Wrap(err, "retrieving expired item")
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err = downloadItem(ctx, iaag, di)
|
ldi := custom.ToLiteDriveItemable(di)
|
||||||
|
|
||||||
|
content, err = downloadItem(ctx, iaag, ldi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, clues.Wrap(err, "content download retry")
|
return nil, clues.Wrap(err, "content download retry")
|
||||||
}
|
}
|
||||||
@ -489,7 +494,7 @@ func (oc *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
|
|||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
go func(item models.DriveItemable) {
|
go func(item custom.LiteDriveItemable) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer func() { <-semaphoreCh }()
|
defer func() { <-semaphoreCh }()
|
||||||
|
|
||||||
@ -513,14 +518,14 @@ func (oc *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
|
|||||||
|
|
||||||
type lazyItemGetter struct {
|
type lazyItemGetter struct {
|
||||||
info *details.ItemInfo
|
info *details.ItemInfo
|
||||||
item models.DriveItemable
|
item custom.LiteDriveItemable
|
||||||
driveID string
|
driveID string
|
||||||
suffix string
|
suffix string
|
||||||
itemExtensionFactory []extensions.CreateItemExtensioner
|
itemExtensionFactory []extensions.CreateItemExtensioner
|
||||||
contentGetter func(
|
contentGetter func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
driveID string,
|
driveID string,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
errs *fault.Bus) (io.ReadCloser, error)
|
errs *fault.Bus) (io.ReadCloser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +566,7 @@ func (lig *lazyItemGetter) GetData(
|
|||||||
func (oc *Collection) streamDriveItem(
|
func (oc *Collection) streamDriveItem(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
parentPath *path.Builder,
|
parentPath *path.Builder,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
stats *driveStats,
|
stats *driveStats,
|
||||||
itemExtensionFactory []extensions.CreateItemExtensioner,
|
itemExtensionFactory []extensions.CreateItemExtensioner,
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
@ -584,7 +589,7 @@ func (oc *Collection) streamDriveItem(
|
|||||||
"item_name", clues.Hide(itemName),
|
"item_name", clues.Hide(itemName),
|
||||||
"item_size", itemSize)
|
"item_size", itemSize)
|
||||||
|
|
||||||
item.SetParentReference(setName(item.GetParentReference(), oc.driveName))
|
item.SetParentReference(custom.SetParentName(item.GetParentReference(), oc.driveName))
|
||||||
|
|
||||||
isFile := item.GetFile() != nil
|
isFile := item.GetFile() != nil
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -641,7 +642,7 @@ func (suite *GetDriveItemUnitTestSuite) TestGetDriveItem_error() {
|
|||||||
|
|
||||||
col.handler = mbh
|
col.handler = mbh
|
||||||
|
|
||||||
_, err := col.getDriveItemContent(ctx, "driveID", stubItem, errs)
|
_, err := col.getDriveItemContent(ctx, "driveID", custom.ToLiteDriveItemable(stubItem), errs)
|
||||||
if test.err == nil {
|
if test.err == nil {
|
||||||
assert.NoError(t, err, clues.ToCore(err))
|
assert.NoError(t, err, clues.ToCore(err))
|
||||||
return
|
return
|
||||||
@ -819,7 +820,7 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
|||||||
mbh.GetResps = resps
|
mbh.GetResps = resps
|
||||||
mbh.GetErrs = test.getErr
|
mbh.GetErrs = test.getErr
|
||||||
|
|
||||||
r, err := downloadContent(ctx, mbh, test.muc, item, driveID, count.New())
|
r, err := downloadContent(ctx, mbh, test.muc, custom.ToLiteDriveItemable(item), driveID, count.New())
|
||||||
test.expect(t, r)
|
test.expect(t, r)
|
||||||
test.expectErr(t, err, clues.ToCore(err))
|
test.expectErr(t, err, clues.ToCore(err))
|
||||||
})
|
})
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -955,7 +956,9 @@ func (c *Collections) processItem(
|
|||||||
"item_is_folder", isFolder)
|
"item_is_folder", isFolder)
|
||||||
|
|
||||||
if item.GetMalware() != nil {
|
if item.GetMalware() != nil {
|
||||||
addtl := graph.ItemInfo(item)
|
// TODO(pandeyabs): Fix this after we move conversion logic to the top of this
|
||||||
|
// func.
|
||||||
|
addtl := graph.ItemInfo(custom.ToLiteDriveItemable(item))
|
||||||
skip := fault.FileSkip(fault.SkipMalware, driveID, itemID, itemName, addtl)
|
skip := fault.FileSkip(fault.SkipMalware, driveID, itemID, itemName, addtl)
|
||||||
|
|
||||||
if isFolder {
|
if isFolder {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -464,7 +465,7 @@ func (c *Collections) addFolderToTree(
|
|||||||
driveID,
|
driveID,
|
||||||
folderID,
|
folderID,
|
||||||
folderName,
|
folderName,
|
||||||
graph.ItemInfo(folder))
|
graph.ItemInfo(custom.ToLiteDriveItemable(folder)))
|
||||||
|
|
||||||
logger.Ctx(ctx).Infow("malware detected")
|
logger.Ctx(ctx).Infow("malware detected")
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package drive
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -11,6 +10,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ BackupHandler = &groupBackupHandler{}
|
var _ BackupHandler = &groupBackupHandler{}
|
||||||
@ -105,7 +105,7 @@ func (h groupBackupHandler) SitePathPrefix(tenantID string) (path.Path, error) {
|
|||||||
func (h groupBackupHandler) AugmentItemInfo(
|
func (h groupBackupHandler) AugmentItemInfo(
|
||||||
dii details.ItemInfo,
|
dii details.ItemInfo,
|
||||||
resource idname.Provider,
|
resource idname.Provider,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
size int64,
|
size int64,
|
||||||
parentPath *path.Builder,
|
parentPath *path.Builder,
|
||||||
) details.ItemInfo {
|
) details.ItemInfo {
|
||||||
|
|||||||
@ -3,12 +3,11 @@ package drive
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getItemCreator(item models.DriveItemable) string {
|
func getItemCreator(item custom.LiteDriveItemable) string {
|
||||||
if item.GetCreatedBy() == nil || item.GetCreatedBy().GetUser() == nil {
|
if item.GetCreatedBy() == nil || item.GetCreatedBy().GetUser() == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -30,7 +29,7 @@ func getItemCreator(item models.DriveItemable) string {
|
|||||||
return *ed.(*string)
|
return *ed.(*string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getItemDriveInfo(item models.DriveItemable) (string, string) {
|
func getItemDriveInfo(item custom.LiteDriveItemable) (string, string) {
|
||||||
if item.GetParentReference() == nil {
|
if item.GetParentReference() == nil {
|
||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ItemInfoAugmenter interface {
|
type ItemInfoAugmenter interface {
|
||||||
@ -23,7 +24,7 @@ type ItemInfoAugmenter interface {
|
|||||||
AugmentItemInfo(
|
AugmentItemInfo(
|
||||||
dii details.ItemInfo,
|
dii details.ItemInfo,
|
||||||
resource idname.Provider,
|
resource idname.Provider,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
size int64,
|
size int64,
|
||||||
parentPath *path.Builder,
|
parentPath *path.Builder,
|
||||||
) details.ItemInfo
|
) details.ItemInfo
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -18,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -34,7 +34,7 @@ var downloadURLKeys = []string{
|
|||||||
func downloadItem(
|
func downloadItem(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ag api.Getter,
|
ag api.Getter,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
) (io.ReadCloser, error) {
|
) (io.ReadCloser, error) {
|
||||||
if item == nil {
|
if item == nil {
|
||||||
return nil, clues.New("nil item")
|
return nil, clues.New("nil item")
|
||||||
@ -152,7 +152,7 @@ func downloadItemMeta(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
getter GetItemPermissioner,
|
getter GetItemPermissioner,
|
||||||
driveID string,
|
driveID string,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
) (io.ReadCloser, int, error) {
|
) (io.ReadCloser, int, error) {
|
||||||
meta := metadata.Metadata{
|
meta := metadata.Metadata{
|
||||||
FileName: ptr.Val(item.GetName()),
|
FileName: ptr.Val(item.GetName()),
|
||||||
@ -204,13 +204,3 @@ func driveItemWriter(
|
|||||||
|
|
||||||
return iw, ptr.Val(icu.GetUploadUrl()), nil
|
return iw, ptr.Val(icu.GetUploadUrl()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setName(orig models.ItemReferenceable, driveName string) models.ItemReferenceable {
|
|
||||||
if orig == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
orig.SetName(&driveName)
|
|
||||||
|
|
||||||
return orig
|
|
||||||
}
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ItemIntegrationSuite struct {
|
type ItemIntegrationSuite struct {
|
||||||
@ -123,7 +124,7 @@ func (suite *ItemIntegrationSuite) TestItemReader_oneDrive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read data for the file
|
// Read data for the file
|
||||||
itemData, err := downloadItem(ctx, bh, driveItem)
|
itemData, err := downloadItem(ctx, bh, custom.ToLiteDriveItemable(driveItem))
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
size, err := io.Copy(io.Discard, itemData)
|
size, err := io.Copy(io.Discard, itemData)
|
||||||
@ -462,7 +463,7 @@ func (suite *ItemUnitTestSuite) TestDownloadItem() {
|
|||||||
mg := mockGetter{
|
mg := mockGetter{
|
||||||
GetFunc: test.GetFunc,
|
GetFunc: test.GetFunc,
|
||||||
}
|
}
|
||||||
rc, err := downloadItem(ctx, mg, test.itemFunc())
|
rc, err := downloadItem(ctx, mg, custom.ToLiteDriveItemable(test.itemFunc()))
|
||||||
test.errorExpected(t, err, clues.ToCore(err))
|
test.errorExpected(t, err, clues.ToCore(err))
|
||||||
test.rcExpected(t, rc)
|
test.rcExpected(t, rc)
|
||||||
})
|
})
|
||||||
@ -521,7 +522,7 @@ func (suite *ItemUnitTestSuite) TestDownloadItem_ConnectionResetErrorOnFirstRead
|
|||||||
mg := mockGetter{
|
mg := mockGetter{
|
||||||
GetFunc: GetFunc,
|
GetFunc: GetFunc,
|
||||||
}
|
}
|
||||||
rc, err := downloadItem(ctx, mg, itemFunc())
|
rc, err := downloadItem(ctx, mg, custom.ToLiteDriveItemable(itemFunc()))
|
||||||
errorExpected(t, err, clues.ToCore(err))
|
errorExpected(t, err, clues.ToCore(err))
|
||||||
rcExpected(t, rc)
|
rcExpected(t, rc)
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -863,7 +864,7 @@ func restoreFile(
|
|||||||
dii := ir.AugmentItemInfo(
|
dii := ir.AugmentItemInfo(
|
||||||
details.ItemInfo{},
|
details.ItemInfo{},
|
||||||
rcc.ProtectedResource,
|
rcc.ProtectedResource,
|
||||||
newItem,
|
custom.ToLiteDriveItemable(newItem),
|
||||||
written,
|
written,
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
type baseSiteHandler struct {
|
type baseSiteHandler struct {
|
||||||
@ -33,7 +34,7 @@ func (h baseSiteHandler) NewDrivePager(
|
|||||||
func (h baseSiteHandler) AugmentItemInfo(
|
func (h baseSiteHandler) AugmentItemInfo(
|
||||||
dii details.ItemInfo,
|
dii details.ItemInfo,
|
||||||
resource idname.Provider,
|
resource idname.Provider,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
size int64,
|
size int64,
|
||||||
parentPath *path.Builder,
|
parentPath *path.Builder,
|
||||||
) details.ItemInfo {
|
) details.ItemInfo {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -42,7 +43,7 @@ func (h baseUserDriveHandler) NewDrivePager(
|
|||||||
func (h baseUserDriveHandler) AugmentItemInfo(
|
func (h baseUserDriveHandler) AugmentItemInfo(
|
||||||
dii details.ItemInfo,
|
dii details.ItemInfo,
|
||||||
resource idname.Provider,
|
resource idname.Provider,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
size int64,
|
size int64,
|
||||||
parentPath *path.Builder,
|
parentPath *path.Builder,
|
||||||
) details.ItemInfo {
|
) details.ItemInfo {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
apiMock "github.com/alcionai/corso/src/pkg/services/m365/api/mock"
|
apiMock "github.com/alcionai/corso/src/pkg/services/m365/api/mock"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -165,7 +166,7 @@ func (h BackupHandler[T]) NewLocationIDer(driveID string, elems ...string) detai
|
|||||||
func (h BackupHandler[T]) AugmentItemInfo(
|
func (h BackupHandler[T]) AugmentItemInfo(
|
||||||
details.ItemInfo,
|
details.ItemInfo,
|
||||||
idname.Provider,
|
idname.Provider,
|
||||||
models.DriveItemable,
|
custom.LiteDriveItemable,
|
||||||
int64,
|
int64,
|
||||||
*path.Builder,
|
*path.Builder,
|
||||||
) details.ItemInfo {
|
) details.ItemInfo {
|
||||||
@ -405,7 +406,7 @@ func (h RestoreHandler) NewDrivePager(string, []string) pagers.NonDeltaHandler[m
|
|||||||
func (h *RestoreHandler) AugmentItemInfo(
|
func (h *RestoreHandler) AugmentItemInfo(
|
||||||
details.ItemInfo,
|
details.ItemInfo,
|
||||||
idname.Provider,
|
idname.Provider,
|
||||||
models.DriveItemable,
|
custom.LiteDriveItemable,
|
||||||
int64,
|
int64,
|
||||||
*path.Builder,
|
*path.Builder,
|
||||||
) details.ItemInfo {
|
) details.ItemInfo {
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/common/str"
|
"github.com/alcionai/corso/src/internal/common/str"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/filters"
|
"github.com/alcionai/corso/src/pkg/filters"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -510,18 +510,20 @@ func appendIf(a []any, k string, v *string) []any {
|
|||||||
|
|
||||||
// ItemInfo gathers potentially useful information about a drive item,
|
// ItemInfo gathers potentially useful information about a drive item,
|
||||||
// and aggregates that data into a map.
|
// and aggregates that data into a map.
|
||||||
func ItemInfo(item models.DriveItemable) map[string]any {
|
func ItemInfo(item custom.LiteDriveItemable) map[string]any {
|
||||||
m := map[string]any{}
|
m := map[string]any{}
|
||||||
|
|
||||||
creator := item.GetCreatedByUser()
|
// TODO(pandeyabs): These fields are not available in the LiteDriveItemable
|
||||||
if creator != nil {
|
// yet. We need to add them.
|
||||||
m[fault.AddtlCreatedBy] = ptr.Val(creator.GetId())
|
// creator := item.GetCreatedByUser()
|
||||||
}
|
// if creator != nil {
|
||||||
|
// m[fault.AddtlCreatedBy] = ptr.Val(creator.GetId())
|
||||||
|
// }
|
||||||
|
|
||||||
lastmodder := item.GetLastModifiedByUser()
|
// lastmodder := item.GetLastModifiedByUser()
|
||||||
if lastmodder != nil {
|
// if lastmodder != nil {
|
||||||
m[fault.AddtlLastModBy] = ptr.Val(lastmodder.GetId())
|
// m[fault.AddtlLastModBy] = ptr.Val(lastmodder.GetId())
|
||||||
}
|
// }
|
||||||
|
|
||||||
parent := item.GetParentReference()
|
parent := item.GetParentReference()
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
@ -538,10 +540,10 @@ func ItemInfo(item models.DriveItemable) map[string]any {
|
|||||||
m[fault.AddtlContainerPath] = containerPath
|
m[fault.AddtlContainerPath] = containerPath
|
||||||
}
|
}
|
||||||
|
|
||||||
malware := item.GetMalware()
|
// malware := item.GetMalware()
|
||||||
if malware != nil {
|
// if malware != nil {
|
||||||
m[fault.AddtlMalwareDesc] = ptr.Val(malware.GetDescription())
|
// m[fault.AddtlMalwareDesc] = ptr.Val(malware.GetDescription())
|
||||||
}
|
// }
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
graphTD "github.com/alcionai/corso/src/pkg/services/m365/api/graph/testdata"
|
graphTD "github.com/alcionai/corso/src/pkg/services/m365/api/graph/testdata"
|
||||||
|
"github.com/alcionai/corso/src/pkg/services/m365/custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GraphErrorsUnitSuite struct {
|
type GraphErrorsUnitSuite struct {
|
||||||
@ -532,7 +533,7 @@ func (suite *GraphErrorsUnitSuite) TestMalwareInfo() {
|
|||||||
fault.AddtlMalwareDesc: malDesc,
|
fault.AddtlMalwareDesc: malDesc,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(suite.T(), expect, ItemInfo(i))
|
assert.Equal(suite.T(), expect, ItemInfo(custom.ToLiteDriveItemable(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GraphErrorsUnitSuite) TestIsErrFolderExists() {
|
func (suite *GraphErrorsUnitSuite) TestIsErrFolderExists() {
|
||||||
|
|||||||
@ -337,3 +337,14 @@ func ToLiteDriveItemable(item models.DriveItemable) LiteDriveItemable {
|
|||||||
|
|
||||||
return di
|
return di
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetParentName(orig parentReferenceable, driveName string) parentReferenceable {
|
||||||
|
if orig == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pr := orig.(*parentRef)
|
||||||
|
pr.name = driveName
|
||||||
|
|
||||||
|
return pr
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user