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.
This commit is contained in:
parent
6fe91e254a
commit
9c0566062e
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user