From e70bf25f6ed1c0ba6e601d003eea14b7a7472f22 Mon Sep 17 00:00:00 2001 From: Danny Date: Wed, 15 Feb 2023 08:30:03 -0500 Subject: [PATCH] GC: Restore: Libraries Workflow (#2511) ## Description Due to recent changes with `Incrementals` restore of Library categories stopped working. This PR will allow for files that do not require special folder permissions to be restored. Changes involve the folder naming format that was coming from the CLI ## Does this PR need a docs update or release note? - [x] :no_entry: No ## Type of change - [x] :bug: Bugfix ## Issue(s) * closes #2489 ## Test Plan - [x] :muscle: Manual --- src/cli/restore/sharepoint.go | 2 +- .../connector/onedrive/drivesource_string.go | 25 +++++++++++++++++++ src/internal/connector/onedrive/restore.go | 3 ++- src/internal/connector/sharepoint/restore.go | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/internal/connector/onedrive/drivesource_string.go diff --git a/src/cli/restore/sharepoint.go b/src/cli/restore/sharepoint.go index 3fd7c252f..55de9b797 100644 --- a/src/cli/restore/sharepoint.go +++ b/src/cli/restore/sharepoint.go @@ -170,7 +170,7 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error { defer utils.CloseRepo(ctx, r) - dest := control.DefaultRestoreDestination(common.SimpleDateTime) + dest := control.DefaultRestoreDestination(common.SimpleDateTimeOneDrive) sel := utils.IncludeSharePointRestoreDataSelectors(opts) utils.FilterSharePointRestoreInfoSelectors(sel, opts) diff --git a/src/internal/connector/onedrive/drivesource_string.go b/src/internal/connector/onedrive/drivesource_string.go new file mode 100644 index 000000000..c746448bc --- /dev/null +++ b/src/internal/connector/onedrive/drivesource_string.go @@ -0,0 +1,25 @@ +// Code generated by "stringer -type=driveSource"; DO NOT EDIT. + +package onedrive + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[unknownDriveSource-0] + _ = x[OneDriveSource-1] + _ = x[SharePointSource-2] +} + +const _driveSource_name = "unknownDriveSourceOneDriveSourceSharePointSource" + +var _driveSource_index = [...]uint8{0, 18, 32, 48} + +func (i driveSource) String() string { + if i < 0 || i >= driveSource(len(_driveSource_index)-1) { + return "driveSource(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _driveSource_name[_driveSource_index[i]:_driveSource_index[i+1]] +} diff --git a/src/internal/connector/onedrive/restore.go b/src/internal/connector/onedrive/restore.go index ed098ad6a..53c64a999 100644 --- a/src/internal/connector/onedrive/restore.go +++ b/src/internal/connector/onedrive/restore.go @@ -234,7 +234,8 @@ func RestoreCollection( restoreFolderElements, parentPerms, colPerms, - permissionIDMappings) + permissionIDMappings, + ) if err != nil { errUpdater(directory.String(), errors.Wrapf(err, "failed to create folders %v", restoreFolderElements)) return metrics, folderPerms, permissionIDMappings, false diff --git a/src/internal/connector/sharepoint/restore.go b/src/internal/connector/sharepoint/restore.go index 3173d5778..bb257ec6b 100644 --- a/src/internal/connector/sharepoint/restore.go +++ b/src/internal/connector/sharepoint/restore.go @@ -70,7 +70,7 @@ func RestoreCollections( service, dc, map[string][]onedrive.UserPermission{}, // Currently permission data is not stored for sharepoint - onedrive.OneDriveSource, + onedrive.SharePointSource, dest.ContainerName, deets, errUpdater,