Update based on reviewer comments

This commit is contained in:
Ashlie Martinez 2023-02-22 12:04:56 -08:00
parent 3f8308cfc1
commit 98b7665249
3 changed files with 21 additions and 20 deletions

View File

@ -175,11 +175,7 @@ func (c *onedriveCollection) withFile(
name+onedrive.DataFileSuffix,
fileData))
case 1:
fallthrough
case 2:
fallthrough
case 3:
case 1, 2, 3:
c.items = append(c.items, onedriveItemWithData(
c.t,
name+onedrive.DataFileSuffix,
@ -208,14 +204,10 @@ func (c *onedriveCollection) withFolder(
roles []string,
) *onedriveCollection {
switch c.backupVersion {
case 0:
fallthrough
case 3:
case 0, 3:
return c
case 1:
fallthrough
case 2:
case 1, 2:
c.items = append(
c.items,
onedriveMetadata(

View File

@ -13,6 +13,7 @@ import (
"github.com/pkg/errors"
"golang.org/x/exp/maps"
"github.com/alcionai/corso/src/internal/common/ptr"
"github.com/alcionai/corso/src/internal/connector/graph"
"github.com/alcionai/corso/src/internal/connector/support"
"github.com/alcionai/corso/src/internal/data"
@ -563,19 +564,24 @@ func (c *Collections) UpdateCollections(
}
var (
folderPath path.Path
isFolder = item.GetFolder() != nil || item.GetPackage() != nil
itemPath path.Path
isFolder = item.GetFolder() != nil || item.GetPackage() != nil
)
if item.GetName() != nil {
folderPath, err = collectionPath.Append(*item.GetName(), !isFolder)
if item.GetDeleted() == nil {
name := ptr.Val(item.GetName())
if len(name) == 0 {
return clues.New("non-deleted item with empty name").With("item_id", name)
}
itemPath, err = collectionPath.Append(name, !isFolder)
if err != nil {
return err
}
}
// Skip items that don't match the folder selectors we were given.
if shouldSkipDrive(ctx, folderPath, c.matcher, driveName) &&
if shouldSkipDrive(ctx, itemPath, c.matcher, driveName) &&
shouldSkipDrive(ctx, collectionPath, c.matcher, driveName) {
logger.Ctx(ctx).Infof("Skipping path %s", collectionPath.String())
continue
@ -625,9 +631,9 @@ func (c *Collections) UpdateCollections(
// Moved folders don't cause delta results for any subfolders nested in
// them. We need to go through and update paths to handle that. We only
// update newPaths so we don't accidentally clobber previous deletes.
updatePath(newPaths, *item.GetId(), folderPath.String())
updatePath(newPaths, *item.GetId(), itemPath.String())
found, err := updateCollectionPaths(*item.GetId(), c.CollectionMap, folderPath)
found, err := updateCollectionPaths(*item.GetId(), c.CollectionMap, itemPath)
if err != nil {
return err
}
@ -635,7 +641,7 @@ func (c *Collections) UpdateCollections(
if !found {
col := NewCollection(
c.itemClient,
folderPath,
itemPath,
prevPath,
driveID,
c.service,

View File

@ -41,7 +41,10 @@ const (
// name.
// TODO(ashmrtn): Update this to a real value when we merge the file name
// change. Set to MAXINT for now to keep the if-check using it working.
versionWithNameInMeta = math.MaxInt
versionWithNameInMeta = math.MaxInt
// versionWithDataAndMetaFilesInDir moves the .dirmeta entries to the
// directory they belong to instead of being in the parent of the directory
// they belong to.
versionWithDataAndMetaFilesInDir = 3
)