From 9c0566062eca20aa351e9da102da36471e0eac2a Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Tue, 21 Feb 2023 15:26:17 -0800 Subject: [PATCH] Allow creation of empty collections We've gone back and forth as to whether we should save empty folders or not. Long-term it seems like we should be. This starts this process (and simplifies some of the logic). Empty folders will not be able to be restored without further changes though as they are not directly accessible through backup details. --- .../connector/onedrive/collections.go | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/internal/connector/onedrive/collections.go b/src/internal/connector/onedrive/collections.go index de9f63544..9344e708a 100644 --- a/src/internal/connector/onedrive/collections.go +++ b/src/internal/connector/onedrive/collections.go @@ -640,24 +640,19 @@ func (c *Collections) UpdateCollections( } if !found { - // We only create collections for folder that are not - // new. This is so as to not create collections for - // new folders without any files within them. - if prevPath != nil { - col := NewCollection( - c.itemClient, - folderPath, - prevPath, - driveID, - c.service, - c.statusUpdater, - c.source, - c.ctrl, - invalidPrevDelta, - ) - c.CollectionMap[*item.GetId()] = col - c.NumContainers++ - } + col := NewCollection( + c.itemClient, + folderPath, + prevPath, + driveID, + c.service, + c.statusUpdater, + c.source, + c.ctrl, + invalidPrevDelta, + ) + c.CollectionMap[*item.GetId()] = col + c.NumContainers++ } if c.source != OneDriveSource { @@ -743,14 +738,6 @@ func (c *Collections) UpdateCollections( if !removed { return clues.New("removing from prev collection").With("item_id", *item.GetId()) } - - // If that was the only item in that collection and is - // not getting added back, delete the collection - if itemColID != collectionID && - pcollection.IsEmpty() && - pcollection.State() == data.NewState { - delete(c.CollectionMap, itemColID) - } } itemCollection[*item.GetId()] = collectionID