Abhishek Pandey 50ba30539a
Persist metadata files for group mailbox posts (#5135)
<!-- PR description-->

* Each post now has a `.data` and `.meta` file.
* I've only made changes to groups lazy reader to keep this PR short. Note that channels don't have meta/data file concepts, we don't want to accidentally enable this for channels. Given channels doesn't use lazy reader, this is safe to do short term.
* I'll be adding small follow up PRs to 1) Make sure channels files don't get assigned `.data` suffix. 2) Support for data and meta files for prefetch conversations backup. 

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
2024-01-30 11:10:07 +00:00

120 lines
3.0 KiB
Go

package groups
import (
"context"
"io"
"github.com/microsoft/kiota-abstractions-go/serialization"
"github.com/alcionai/corso/src/pkg/backup/details"
"github.com/alcionai/corso/src/pkg/path"
"github.com/alcionai/corso/src/pkg/selectors"
"github.com/alcionai/corso/src/pkg/services/m365/api"
"github.com/alcionai/corso/src/pkg/services/m365/api/graph"
"github.com/alcionai/corso/src/pkg/services/m365/api/pagers"
)
// itemer standardizes common behavior that can be expected from all
// items within a groups collection backup.
type groupsItemer interface {
serialization.Parsable
graph.GetIDer
graph.GetLastModifiedDateTimer
}
type backupHandler[C graph.GetIDer, I groupsItemer] interface {
getItemer[I]
getContainerser[C]
getContainerItemIDser
getItemAndAugmentInfoer[C, I]
includeContainerer[C]
canonicalPather
canMakeDeltaQuerieser
}
type getItemAndAugmentInfoer[C graph.GetIDer, I groupsItemer] interface {
getItemer[I]
getItemMetadataer[C, I]
augmentItemInfoer[C]
supportsItemMetadataer[C, I]
}
type augmentItemInfoer[C graph.GetIDer] interface {
// augmentItemInfo completes the groupInfo population with any data
// owned by the container and not accessible to the item.
augmentItemInfo(*details.GroupsInfo, C)
}
type getItemer[I groupsItemer] interface {
getItem(
ctx context.Context,
protectedResource string,
containerIDs path.Elements,
itemID string,
) (I, *details.GroupsInfo, error)
}
type getItemMetadataer[C graph.GetIDer, I groupsItemer] interface {
getItemMetadata(
ctx context.Context,
c C,
) (io.ReadCloser, int, error)
}
type supportsItemMetadataer[C graph.GetIDer, I groupsItemer] interface {
supportsItemMetadata() bool
}
// gets all containers for the resource
type getContainerser[C graph.GetIDer] interface {
getContainers(
ctx context.Context,
cc api.CallConfig,
) ([]container[C], error)
}
// gets all item IDs (by delta, if possible) in the container
type getContainerItemIDser interface {
getContainerItemIDs(
ctx context.Context,
containerPath path.Elements,
prevDelta string,
cc api.CallConfig,
) (pagers.AddedAndRemoved, error)
}
// includeContainer evaluates whether the container is included
// in the provided scope.
type includeContainerer[C graph.GetIDer] interface {
includeContainer(
c C,
scope selectors.GroupsScope,
) bool
}
// canonicalPath constructs the service and category specific path for
// the given builder.
type canonicalPather interface {
canonicalPath(
storageDir path.Elements,
tenantID string,
) (path.Path, error)
}
// canMakeDeltaQueries evaluates whether the handler can support a
// delta query when enumerating its items.
type canMakeDeltaQuerieser interface {
canMakeDeltaQueries() bool
}
// ---------------------------------------------------------------------------
// Container management
// ---------------------------------------------------------------------------
type container[C graph.GetIDer] struct {
storageDirFolders path.Elements
humanLocation path.Elements
canMakeDeltaQueries bool
container C
}