Documentation ¶
Index ¶
- Constants
- func CreateRestoreFolders(ctx context.Context, rh RestoreHandler, drivePath *path.DrivePath, ...) (string, error)
- func DeserializeMap[T any](reader io.ReadCloser, alreadyFound map[string]T) error
- func DeserializeMetadata(ctx context.Context, cols []data.RestoreCollection) (map[string]string, map[string]map[string]string, bool, error)
- func DeserializeMetadataFiles(ctx context.Context, colls []data.RestoreCollection, counter *count.Bus) ([]store.MetadataFile, error)
- func FetchAndReadMetadata(ctx context.Context, fibn data.FetchItemByNamer, metaName string) (odmetadata.Metadata, error)
- func NewExportCollection(baseDir string, backingCollection []data.RestoreCollection, backupVersion int, ...) export.Collectioner
- func NewFolderCache() *folderCache
- func NewGroupBackupHandler(groupID, siteID string, ac api.Drives, scope selectors.GroupsScope) groupBackupHandler
- func NewRestoreCaches(backupDriveIDNames idname.Cacher) *restoreCaches
- func NewSiteBackupHandler(ac api.Drives, siteID string, scope selectors.SharePointScope, ...) siteBackupHandler
- func NewSiteRestoreHandler(ac api.Client, service path.ServiceType) siteRestoreHandler
- func NewUserDriveBackupHandler(ac api.Drives, userID string, scope selectors.OneDriveScope) *userDriveBackupHandler
- func NewUserDriveRestoreHandler(ac api.Client) *userDriveRestoreHandler
- func RestoreCollection(ctx context.Context, rh RestoreHandler, rcc inject.RestoreConsumerConfig, ...) (support.CollectionMetrics, error)
- func RestorePermissions(ctx context.Context, rh RestoreHandler, driveID string, itemID string, ...)
- func UpdateLinkShares(ctx context.Context, upils updateDeleteItemLinkSharer, driveID string, ...) (bool, error)
- func UpdatePermissions(ctx context.Context, udip updateDeleteItemPermissioner, driveID string, ...) error
- type BackupHandler
- type Collection
- func (oc *Collection) Add(item *custom.DriveItem) bool
- func (oc Collection) ContainsItem(item *custom.DriveItem) bool
- func (oc Collection) CountAddedItems() int
- func (oc Collection) DoNotMergeItems() bool
- func (oc *Collection) FullPath() path.Path
- func (oc *Collection) IsEmpty() bool
- func (oc *Collection) Items(ctx context.Context, errs *fault.Bus) <-chan data.Item
- func (oc Collection) LocationPath() *path.Builder
- func (oc Collection) PreviousLocationPath() details.LocationIDer
- func (oc Collection) PreviousPath() path.Path
- func (oc *Collection) Remove(itemID string) bool
- func (oc *Collection) SetFullPath(curPath path.Path)
- func (oc Collection) State() data.CollectionState
- type Collections
- func (c *Collections) Get(ctx context.Context, prevMetadata []data.RestoreCollection, ...) ([]data.BackupCollection, bool, error)
- func (c *Collections) PopulateDriveCollections(ctx context.Context, driveID, driveName string, oldPrevPaths map[string]string, ...) (pagers.DeltaUpdate, map[string]string, error)
- type DeleteItemPermissioner
- type DeleteItemer
- type EnumerateDriveItemsDeltaer
- type GetAllIDsAndNameser
- type GetDrivePagerAndRootFolderer
- type GetFolderByNamer
- type GetItemPermissioner
- type GetItemer
- type GetItemsByCollisionKeyser
- type GetRootFolderer
- type ItemInfoAugmenter
- type NewDrivePagerer
- type NewItemContentUploader
- type PostDriveAndGetRootFolderer
- type PostDriver
- type PostItemInContainerer
- type ResourceIDNames
- type RestoreHandler
- type UpdateItemLinkSharer
- type UpdateItemPermissioner
Constants ¶
const (
// Used to compare in case of OneNote files
MaxOneNoteFileSize = 2 * 1024 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func CreateRestoreFolders ¶
func CreateRestoreFolders( ctx context.Context, rh RestoreHandler, drivePath *path.DrivePath, restoreDir *path.Builder, folderPath path.Path, folderMetadata odmetadata.Metadata, caches *restoreCaches, restorePerms bool, errs *fault.Bus, ) (string, error)
CreateRestoreFolders creates the restore folder hierarchy in the specified drive and returns the folder ID of the last folder entry in the hierarchy. Permissions are only applied to the last folder in the hierarchy. Passing nil for the permissions results in just creating the folder(s). folderCache is mutated, as a side effect of populating the items.
func DeserializeMap ¶
func DeserializeMap[T any](reader io.ReadCloser, alreadyFound map[string]T) error
DeserializeMap takes an reader and a map of already deserialized items and adds the newly deserialized items to alreadyFound. Items are only added to alreadyFound if none of the keys in the freshly deserialized map already exist in alreadyFound. reader is closed at the end of this function.
func DeserializeMetadata ¶
func DeserializeMetadataFiles ¶
func DeserializeMetadataFiles( ctx context.Context, colls []data.RestoreCollection, counter *count.Bus, ) ([]store.MetadataFile, error)
func FetchAndReadMetadata ¶
func FetchAndReadMetadata( ctx context.Context, fibn data.FetchItemByNamer, metaName string, ) (odmetadata.Metadata, error)
func NewExportCollection ¶
func NewExportCollection( baseDir string, backingCollection []data.RestoreCollection, backupVersion int, stats *metrics.ExportStats, ) export.Collectioner
func NewFolderCache ¶
func NewFolderCache() *folderCache
func NewGroupBackupHandler ¶
func NewGroupBackupHandler( groupID, siteID string, ac api.Drives, scope selectors.GroupsScope, ) groupBackupHandler
func NewRestoreCaches ¶
func NewSiteBackupHandler ¶
func NewSiteBackupHandler( ac api.Drives, siteID string, scope selectors.SharePointScope, service path.ServiceType, ) siteBackupHandler
func NewSiteRestoreHandler ¶
func NewSiteRestoreHandler(ac api.Client, service path.ServiceType) siteRestoreHandler
func NewUserDriveBackupHandler ¶
func NewUserDriveBackupHandler(ac api.Drives, userID string, scope selectors.OneDriveScope) *userDriveBackupHandler
func RestoreCollection ¶
func RestoreCollection( ctx context.Context, rh RestoreHandler, rcc inject.RestoreConsumerConfig, dc data.RestoreCollection, caches *restoreCaches, deets *details.Builder, fallbackDriveName string, errs *fault.Bus, ctr *count.Bus, ) (support.CollectionMetrics, error)
RestoreCollection handles restoration of an individual collection. returns: - the collection's item and byte count metrics - the updated metadata map that include metadata for folders in this collection - error, if any besides recoverable
func RestorePermissions ¶
func RestorePermissions( ctx context.Context, rh RestoreHandler, driveID string, itemID string, itemPath path.Path, current odmetadata.Metadata, caches *restoreCaches, errs *fault.Bus, )
RestorePermissions takes in the permissions of an item, computes what permissions need to added and removed based on the parent folder metas and uses that to add/remove the necessary permissions on onedrive items.
func UpdateLinkShares ¶
func UpdatePermissions ¶
func UpdatePermissions( ctx context.Context, udip updateDeleteItemPermissioner, driveID string, itemID string, permAdded, permRemoved []odmetadata.Permission, oldPermIDToNewID syncd.MapTo[string], errs *fault.Bus, ) error
UpdatePermissions takes in the set of permission to be added and removed from an item to bring it to the desired state.
Types ¶
type BackupHandler ¶
type BackupHandler interface { ItemInfoAugmenter api.Getter GetItemPermissioner GetItemer GetRootFolderer NewDrivePagerer EnumerateDriveItemsDeltaer // PathPrefix constructs the service and category specific path prefix for // the given values. PathPrefix(tenantID, driveID string) (path.Path, error) // MetadataPathPrefix returns the prefix path for metadata MetadataPathPrefix(tenantID string) (path.Path, error) // CanonicalPath constructs the service and category specific path for // the given values. CanonicalPath(folders *path.Builder, tenantID string) (path.Path, error) // ServiceCat returns the service and category used by this implementation. ServiceCat() (path.ServiceType, path.CategoryType) // FormatDisplayPath creates a human-readable string to represent the // provided path. FormatDisplayPath(driveName string, parentPath *path.Builder) string NewLocationIDer(driveID string, elems ...string) details.LocationIDer // scope wrapper funcs IsAllPass() bool IncludesDir(dir string) bool }
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection represents a set of OneDrive objects retrieved from M365
func NewCollection ¶
func NewCollection( handler BackupHandler, resource idname.Provider, currPath path.Path, prevPath path.Path, driveID, driveName string, statusUpdater support.StatusUpdater, ctrlOpts control.Options, isPackageOrChildOfPackage bool, doNotMergeItems bool, urlCache getItemPropertyer, counter *count.Bus, ) (*Collection, error)
NewCollection creates a Collection
func (*Collection) Add ¶
func (oc *Collection) Add(item *custom.DriveItem) bool
Adds an itemID to the collection. This will make it eligible to be populated. The return values denotes if the item was previously present or is new one.
func (Collection) ContainsItem ¶
func (oc Collection) ContainsItem(item *custom.DriveItem) bool
ContainsItem returns true if the collection has the given item as one of its children.
func (Collection) CountAddedItems ¶
func (oc Collection) CountAddedItems() int
AddedItems returns the number of non-deleted items in the collection.
func (Collection) DoNotMergeItems ¶
func (oc Collection) DoNotMergeItems() bool
func (*Collection) FullPath ¶
func (oc *Collection) FullPath() path.Path
func (*Collection) IsEmpty ¶
func (oc *Collection) IsEmpty() bool
IsEmpty check if a collection does not contain any items
func (Collection) LocationPath ¶
func (oc Collection) LocationPath() *path.Builder
func (Collection) PreviousLocationPath ¶
func (oc Collection) PreviousLocationPath() details.LocationIDer
func (Collection) PreviousPath ¶
func (oc Collection) PreviousPath() path.Path
func (*Collection) Remove ¶
func (oc *Collection) Remove(itemID string) bool
Remove removes a item from the collection
func (*Collection) SetFullPath ¶
func (oc *Collection) SetFullPath(curPath path.Path)
func (Collection) State ¶
func (oc Collection) State() data.CollectionState
type Collections ¶
type Collections struct { // collectionMap allows lookup of the data.BackupCollection // for a OneDrive folder. // driveID -> itemID -> collection CollectionMap map[string]map[string]*Collection // Track stats from drive enumeration. Represents the items backed up. NumItems int NumFiles int NumContainers int // contains filtered or unexported fields }
Collections is used to retrieve drive data for a resource owner, which can be either a user or a sharepoint site.
func NewCollections ¶
func NewCollections( bh BackupHandler, tenantID string, protectedResource idname.Provider, statusUpdater support.StatusUpdater, ctrlOpts control.Options, counter *count.Bus, ) *Collections
func (*Collections) Get ¶
func (c *Collections) Get( ctx context.Context, prevMetadata []data.RestoreCollection, globalExcludeItemIDs *prefixmatcher.StringSetMatchBuilder, errs *fault.Bus, ) ([]data.BackupCollection, bool, error)
Retrieves drive data as set of `data.Collections`.
func (*Collections) PopulateDriveCollections ¶
func (c *Collections) PopulateDriveCollections( ctx context.Context, driveID, driveName string, oldPrevPaths map[string]string, excludedItemIDs map[string]struct{}, topLevelPackages map[string]struct{}, prevDeltaLink string, counter *count.Bus, errs *fault.Bus, ) (pagers.DeltaUpdate, map[string]string, error)
PopulateDriveCollections initializes and adds the provided drive items to Collections A new collection is created for every drive folder. Along with populating the collection items and updating the excluded item IDs, this func returns the current DeltaUpdate and PreviousPaths for metadata records.
type DeleteItemPermissioner ¶
type DeleteItemer ¶
type EnumerateDriveItemsDeltaer ¶
type EnumerateDriveItemsDeltaer interface { EnumerateDriveItemsDelta( ctx context.Context, driveID, prevDeltaLink string, cc api.CallConfig, ) pagers.NextPageResulter[models.DriveItemable] }
type GetAllIDsAndNameser ¶
type GetDrivePagerAndRootFolderer ¶
type GetDrivePagerAndRootFolderer interface { GetRootFolderer NewDrivePagerer }
type GetFolderByNamer ¶
type GetItemPermissioner ¶
type GetItemsByCollisionKeyser ¶
type GetItemsByCollisionKeyser interface { // GetItemsInContainerByCollisionKey looks up all items currently in // the container, and returns them in a map[collisionKey]itemID. // The collision key is uniquely defined by each category of data. // Collision key checks are used during restore to handle the on- // collision restore configurations that cause the item restore to get // skipped, replaced, or copied. GetItemsInContainerByCollisionKey( ctx context.Context, driveID, containerID string, ) (map[string]api.DriveItemIDType, error) }
type GetRootFolderer ¶
type ItemInfoAugmenter ¶
type ItemInfoAugmenter interface { // AugmentItemInfo will populate a details.<Service>Info struct // with properties from the drive item. ItemSize is passed in // separately for restore processes because the local itemable // doesn't have its size value updated as a side effect of creation, // and kiota drops any SetSize update. AugmentItemInfo( dii details.ItemInfo, resource idname.Provider, item *custom.DriveItem, size int64, parentPath *path.Builder, ) details.ItemInfo }
type NewDrivePagerer ¶
type NewItemContentUploader ¶
type PostDriveAndGetRootFolderer ¶
type PostDriveAndGetRootFolderer interface { PostDriver GetRootFolderer }
type PostDriver ¶
type PostItemInContainerer ¶
type PostItemInContainerer interface { PostItemInContainer( ctx context.Context, driveID, parentFolderID string, newItem models.DriveItemable, onCollision control.CollisionPolicy, ) (models.DriveItemable, error) }
type RestoreHandler ¶
type UpdateItemLinkSharer ¶
type UpdateItemLinkSharer interface { context.Context, driveID, itemID string, body *drives.ItemItemsItemCreateLinkPostRequestBody, ) (models.Permissionable, error) }ctx
type UpdateItemPermissioner ¶
type UpdateItemPermissioner interface { PostItemPermissionUpdate( ctx context.Context, driveID, itemID string, body *drives.ItemItemsItemInvitePostRequestBody, ) (drives.ItemItemsItemInviteResponseable, error) }