Remove remaining refs to msft stores

This commit is contained in:
Abhishek Pandey 2023-11-28 22:24:48 -08:00
parent b5a400b896
commit 178ae0d465

View File

@ -4,6 +4,7 @@ import (
"time" "time"
"github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/ptr"
"github.com/alcionai/corso/src/internal/common/str"
"github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/microsoftgraph/msgraph-sdk-go/models"
) )
@ -58,11 +59,11 @@ type folderDriveItem struct {
type fileDriveItem struct { type fileDriveItem struct {
isFile bool isFile bool
mimeType *string mimeType string
} }
func (fdi *fileDriveItem) GetMimeType() *string { func (fdi *fileDriveItem) GetMimeType() *string {
return fdi.mimeType return &fdi.mimeType
} }
type packageDriveItem struct { type packageDriveItem struct {
@ -70,26 +71,26 @@ type packageDriveItem struct {
} }
type parentReference struct { type parentReference struct {
path *string path string
id *string id string
name *string name string
driveId *string driveId string
} }
func (pr *parentReference) GetPath() *string { func (pr *parentReference) GetPath() *string {
return pr.path return &pr.path
} }
func (pr *parentReference) GetId() *string { func (pr *parentReference) GetId() *string {
return pr.id return &pr.id
} }
func (pr *parentReference) GetName() *string { func (pr *parentReference) GetName() *string {
return pr.name return &pr.name
} }
func (pr *parentReference) GetDriveId() *string { func (pr *parentReference) GetDriveId() *string {
return pr.driveId return &pr.driveId
} }
type itemShared struct { type itemShared struct {
@ -135,8 +136,8 @@ type CorsoDriveItem struct {
ParentReference parentReferenceable ParentReference parentReferenceable
Shared itemSharedable Shared itemSharedable
CreatedBy itemIdentitySetable CreatedBy itemIdentitySetable
CreatedDateTime *time.Time CreatedDateTime time.Time
LastModifiedDateTime *time.Time LastModifiedDateTime time.Time
Malware malwareable Malware malwareable
Deleted deletedable Deleted deletedable
Root itemRootable Root itemRootable
@ -170,6 +171,7 @@ func (c *CorsoDriveItem) GetParentReference() parentReferenceable {
return c.ParentReference return c.ParentReference
} }
// TODO: Should we only support GETs?
func (c *CorsoDriveItem) SetParentReference(parent parentReferenceable) { func (c *CorsoDriveItem) SetParentReference(parent parentReferenceable) {
c.ParentReference = parent c.ParentReference = parent
} }
@ -187,11 +189,11 @@ func (c *CorsoDriveItem) GetCreatedBy() itemIdentitySetable {
} }
func (c *CorsoDriveItem) GetCreatedDateTime() *time.Time { func (c *CorsoDriveItem) GetCreatedDateTime() *time.Time {
return c.CreatedDateTime return &c.CreatedDateTime
} }
func (c *CorsoDriveItem) GetLastModifiedDateTime() *time.Time { func (c *CorsoDriveItem) GetLastModifiedDateTime() *time.Time {
return c.LastModifiedDateTime return &c.LastModifiedDateTime
} }
func (c *CorsoDriveItem) GetMalware() malwareable { func (c *CorsoDriveItem) GetMalware() malwareable {
@ -216,9 +218,23 @@ func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
ID: ptr.Val(item.GetId()), ID: ptr.Val(item.GetId()),
Name: ptr.Val(item.GetName()), Name: ptr.Val(item.GetName()),
Size: ptr.Val(item.GetSize()), Size: ptr.Val(item.GetSize()),
CreatedDateTime: item.GetCreatedDateTime(), CreatedDateTime: ptr.Val(item.GetCreatedDateTime()),
LastModifiedDateTime: item.GetLastModifiedDateTime(), LastModifiedDateTime: ptr.Val(item.GetLastModifiedDateTime()),
AdditionalData: item.GetAdditionalData(), }
// Hacky way to cache the download url. Thats all we use from additional data
// Otherwise, we'll hold a reference to the underlying store which will consume
// lot more memory.
if item.GetFile() != nil {
ad := make(map[string]interface{})
for _, key := range downloadURLKeys {
if v, err := str.AnyValueToString(key, item.GetAdditionalData()); err == nil {
ad[key] = v
break
}
}
cdi.AdditionalData = ad
} }
if item.GetFolder() != nil { if item.GetFolder() != nil {
@ -230,7 +246,7 @@ func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
if item.GetFile() != nil { if item.GetFile() != nil {
cdi.File = &fileDriveItem{ cdi.File = &fileDriveItem{
isFile: true, isFile: true,
mimeType: item.GetFile().GetMimeType(), mimeType: ptr.Val(item.GetFile().GetMimeType()),
} }
} }
@ -242,10 +258,10 @@ func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
if item.GetParentReference() != nil { if item.GetParentReference() != nil {
cdi.ParentReference = &parentReference{ cdi.ParentReference = &parentReference{
id: item.GetParentReference().GetId(), id: ptr.Val(item.GetParentReference().GetId()),
path: item.GetParentReference().GetPath(), path: ptr.Val(item.GetParentReference().GetPath()),
name: item.GetParentReference().GetName(), name: ptr.Val(item.GetParentReference().GetName()),
driveId: item.GetParentReference().GetDriveId(), driveId: ptr.Val(item.GetParentReference().GetDriveId()),
} }
} }