flatten file and folder
This commit is contained in:
parent
d5ac19275f
commit
b444ed328e
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -99,8 +98,8 @@ type CorsoDriveItemable interface {
|
|||||||
GetId() *string
|
GetId() *string
|
||||||
GetName() *string
|
GetName() *string
|
||||||
GetSize() *int64
|
GetSize() *int64
|
||||||
GetFile() models.Fileable
|
GetFile() interface{}
|
||||||
GetFolder() models.Folderable
|
GetFolder() interface{}
|
||||||
GetAdditionalData() map[string]interface{}
|
GetAdditionalData() map[string]interface{}
|
||||||
GetParentReference() models.ItemReferenceable
|
GetParentReference() models.ItemReferenceable
|
||||||
SetParentReference(models.ItemReferenceable)
|
SetParentReference(models.ItemReferenceable)
|
||||||
@ -118,8 +117,8 @@ type CorsoDriveItem struct {
|
|||||||
ID *string
|
ID *string
|
||||||
Name *string
|
Name *string
|
||||||
Size *int64
|
Size *int64
|
||||||
File models.Fileable
|
File interface{}
|
||||||
Folder models.Folderable
|
Folder interface{}
|
||||||
AdditionalData map[string]interface{}
|
AdditionalData map[string]interface{}
|
||||||
ParentReference models.ItemReferenceable
|
ParentReference models.ItemReferenceable
|
||||||
Shared models.Sharedable
|
Shared models.Sharedable
|
||||||
@ -143,11 +142,11 @@ func (c *CorsoDriveItem) GetSize() *int64 {
|
|||||||
return c.Size
|
return c.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CorsoDriveItem) GetFile() models.Fileable {
|
func (c *CorsoDriveItem) GetFile() interface{} {
|
||||||
return c.File
|
return c.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CorsoDriveItem) GetFolder() models.Folderable {
|
func (c *CorsoDriveItem) GetFolder() interface{} {
|
||||||
return c.Folder
|
return c.Folder
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,12 +196,12 @@ func (c *CorsoDriveItem) GetRoot() models.Rootable {
|
|||||||
|
|
||||||
// models.DriveItemable to CorsoDriveItemable
|
// models.DriveItemable to CorsoDriveItemable
|
||||||
func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
|
func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
|
||||||
return &CorsoDriveItem{
|
cdi := &CorsoDriveItem{
|
||||||
ID: item.GetId(),
|
ID: item.GetId(),
|
||||||
Name: item.GetName(),
|
Name: item.GetName(),
|
||||||
Size: item.GetSize(),
|
Size: item.GetSize(),
|
||||||
File: item.GetFile(),
|
File: true,
|
||||||
Folder: item.GetFolder(),
|
Folder: true,
|
||||||
ParentReference: item.GetParentReference(),
|
ParentReference: item.GetParentReference(),
|
||||||
Shared: item.GetShared(),
|
Shared: item.GetShared(),
|
||||||
CreatedBy: item.GetCreatedBy(),
|
CreatedBy: item.GetCreatedBy(),
|
||||||
@ -213,6 +212,16 @@ func ToCorsoDriveItemable(item models.DriveItemable) CorsoDriveItemable {
|
|||||||
Deleted: item.GetDeleted(),
|
Deleted: item.GetDeleted(),
|
||||||
Root: item.GetRoot(),
|
Root: item.GetRoot(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if item.GetFolder() == nil {
|
||||||
|
cdi.Folder = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if item.GetFile() == nil {
|
||||||
|
cdi.File = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return cdi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collection) GetDriveItemsMap() map[string]CorsoDriveItemable {
|
func (c *Collection) GetDriveItemsMap() map[string]CorsoDriveItemable {
|
||||||
@ -420,35 +429,35 @@ func (oc *Collection) getDriveItemContent(
|
|||||||
return nil, clues.Wrap(err, "deleted item").Label(graph.LabelsSkippable)
|
return nil, clues.Wrap(err, "deleted item").Label(graph.LabelsSkippable)
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemMimeType string
|
// var itemMimeType string
|
||||||
if item.GetFile() != nil {
|
// if item.GetFile() != nil {
|
||||||
itemMimeType = ptr.Val(item.GetFile().GetMimeType())
|
// itemMimeType = ptr.Val(item.GetFile().GetMimeType())
|
||||||
}
|
// }
|
||||||
// Skip big OneNote files as they can't be downloaded
|
// // Skip big OneNote files as they can't be downloaded
|
||||||
if clues.HasLabel(err, graph.LabelStatus(http.StatusServiceUnavailable)) &&
|
// if clues.HasLabel(err, graph.LabelStatus(http.StatusServiceUnavailable)) &&
|
||||||
// oc.isPackageOrChildOfPackage && *item.GetSize() >= MaxOneNoteFileSize {
|
// // oc.isPackageOrChildOfPackage && *item.GetSize() >= MaxOneNoteFileSize {
|
||||||
// TODO: We've removed the file size check because it looks like we've seen persistent
|
// // TODO: We've removed the file size check because it looks like we've seen persistent
|
||||||
// 503's with smaller OneNote files also.
|
// // 503's with smaller OneNote files also.
|
||||||
oc.isPackageOrChildOfPackage || strings.EqualFold(itemMimeType, oneNoteMimeType) {
|
// oc.isPackageOrChildOfPackage || strings.EqualFold(itemMimeType, oneNoteMimeType) {
|
||||||
// FIXME: It is possible that in case of a OneNote file we
|
// // FIXME: It is possible that in case of a OneNote file we
|
||||||
// will end up just backing up the `onetoc2` file without
|
// // will end up just backing up the `onetoc2` file without
|
||||||
// the one file which is the important part of the OneNote
|
// // the one file which is the important part of the OneNote
|
||||||
// "item". This will have to be handled during the
|
// // "item". This will have to be handled during the
|
||||||
// restore, or we have to handle it separately by somehow
|
// // restore, or we have to handle it separately by somehow
|
||||||
// deleting the entire collection.
|
// // deleting the entire collection.
|
||||||
logger.
|
// logger.
|
||||||
CtxErr(ctx, err).
|
// CtxErr(ctx, err).
|
||||||
With("skipped_reason", fault.SkipOneNote).
|
// With("skipped_reason", fault.SkipOneNote).
|
||||||
Info("inaccessible one note file")
|
// Info("inaccessible one note file")
|
||||||
// errs.AddSkip(ctx, fault.FileSkip(
|
// // errs.AddSkip(ctx, fault.FileSkip(
|
||||||
// fault.SkipOneNote,
|
// // fault.SkipOneNote,
|
||||||
// driveID,
|
// // driveID,
|
||||||
// itemID,
|
// // itemID,
|
||||||
// itemName,
|
// // itemName,
|
||||||
// graph.ItemInfo(item)))
|
// // graph.ItemInfo(item)))
|
||||||
|
|
||||||
return nil, clues.Wrap(err, "inaccesible oneNote item").Label(graph.LabelsSkippable)
|
// return nil, clues.Wrap(err, "inaccesible oneNote item").Label(graph.LabelsSkippable)
|
||||||
}
|
// }
|
||||||
|
|
||||||
errs.AddRecoverable(
|
errs.AddRecoverable(
|
||||||
ctx,
|
ctx,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user