Move conversion up in the func
This commit is contained in:
parent
cddb5b2d15
commit
8ff7f77267
@ -10,7 +10,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
@ -191,11 +190,9 @@ func newColl(
|
|||||||
// Adds an itemID to the collection. This will make it eligible to be
|
// Adds an itemID to the collection. This will make it eligible to be
|
||||||
// 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 custom.LiteDriveItemable) bool {
|
||||||
liteItem := custom.ToLiteDriveItemable(item)
|
_, found := oc.driveItems[ptr.Val(item.GetId())]
|
||||||
|
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
|
||||||
@ -220,7 +217,7 @@ func (oc *Collection) IsEmpty() bool {
|
|||||||
|
|
||||||
// ContainsItem returns true if the collection has the given item as one of its
|
// ContainsItem returns true if the collection has the given item as one of its
|
||||||
// children.
|
// children.
|
||||||
func (oc Collection) ContainsItem(item models.DriveItemable) bool {
|
func (oc Collection) ContainsItem(item custom.LiteDriveItemable) bool {
|
||||||
_, ok := oc.driveItems[ptr.Val(item.GetId())]
|
_, ok := oc.driveItems[ptr.Val(item.GetId())]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|||||||
@ -233,7 +233,7 @@ func (suite *CollectionUnitSuite) TestCollection() {
|
|||||||
true)
|
true)
|
||||||
|
|
||||||
for i := 0; i < test.numInstances; i++ {
|
for i := 0; i < test.numInstances; i++ {
|
||||||
coll.Add(stubItem)
|
coll.Add(custom.ToLiteDriveItemable(stubItem))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read items from the collection
|
// Read items from the collection
|
||||||
@ -353,7 +353,7 @@ func (suite *CollectionUnitSuite) TestCollectionReadError() {
|
|||||||
true,
|
true,
|
||||||
false)
|
false)
|
||||||
|
|
||||||
coll.Add(stubItem)
|
coll.Add(custom.ToLiteDriveItemable(stubItem))
|
||||||
|
|
||||||
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
@ -423,7 +423,7 @@ func (suite *CollectionUnitSuite) TestCollectionReadUnauthorizedErrorRetry() {
|
|||||||
count.New())
|
count.New())
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
coll.Add(stubItem)
|
coll.Add(custom.ToLiteDriveItemable(stubItem))
|
||||||
|
|
||||||
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
@ -491,7 +491,7 @@ func (suite *CollectionUnitSuite) TestCollectionPermissionBackupLatestModTime()
|
|||||||
true,
|
true,
|
||||||
false)
|
false)
|
||||||
|
|
||||||
coll.Add(stubItem)
|
coll.Add(custom.ToLiteDriveItemable(stubItem))
|
||||||
|
|
||||||
coll.handler = mbh
|
coll.handler = mbh
|
||||||
|
|
||||||
@ -1021,7 +1021,7 @@ func (suite *CollectionUnitSuite) TestItemExtensions() {
|
|||||||
true,
|
true,
|
||||||
false)
|
false)
|
||||||
|
|
||||||
coll.Add(stubItem)
|
coll.Add(custom.ToLiteDriveItemable(stubItem))
|
||||||
|
|
||||||
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
collItem, ok := <-coll.Items(ctx, fault.New(true))
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
|
|||||||
@ -716,7 +716,7 @@ func (c *Collections) handleDelete(
|
|||||||
|
|
||||||
func (c *Collections) getCollectionPath(
|
func (c *Collections) getCollectionPath(
|
||||||
driveID string,
|
driveID string,
|
||||||
item models.DriveItemable,
|
item custom.LiteDriveItemable,
|
||||||
) (path.Path, error) {
|
) (path.Path, error) {
|
||||||
var (
|
var (
|
||||||
pb = odConsts.DriveFolderPrefixBuilder(driveID)
|
pb = odConsts.DriveFolderPrefixBuilder(driveID)
|
||||||
@ -931,7 +931,7 @@ func (c *Collections) PopulateDriveCollections(
|
|||||||
|
|
||||||
func (c *Collections) processItem(
|
func (c *Collections) processItem(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
item models.DriveItemable,
|
di models.DriveItemable,
|
||||||
driveID, driveName string,
|
driveID, driveName string,
|
||||||
oldPrevPaths, currPrevPaths, newPrevPaths map[string]string,
|
oldPrevPaths, currPrevPaths, newPrevPaths map[string]string,
|
||||||
seenFolders map[string]string,
|
seenFolders map[string]string,
|
||||||
@ -944,6 +944,7 @@ func (c *Collections) processItem(
|
|||||||
skipper fault.AddSkipper,
|
skipper fault.AddSkipper,
|
||||||
) error {
|
) error {
|
||||||
var (
|
var (
|
||||||
|
item = custom.ToLiteDriveItemable(di)
|
||||||
itemID = ptr.Val(item.GetId())
|
itemID = ptr.Val(item.GetId())
|
||||||
itemName = ptr.Val(item.GetName())
|
itemName = ptr.Val(item.GetName())
|
||||||
isFolder = item.GetFolder() != nil || item.GetPackageEscaped() != nil
|
isFolder = item.GetFolder() != nil || item.GetPackageEscaped() != nil
|
||||||
@ -956,9 +957,7 @@ func (c *Collections) processItem(
|
|||||||
"item_is_folder", isFolder)
|
"item_is_folder", isFolder)
|
||||||
|
|
||||||
if item.GetMalware() != nil {
|
if item.GetMalware() != nil {
|
||||||
// TODO(pandeyabs): Fix this after we move the ToLiteDriveItemable call
|
addtl := graph.ItemInfo(item)
|
||||||
// to the beginning 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 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user