Add a flag to toggle OneDrive delta incrementals

This will help us while this is still in development. We should be
able to add in features without affecting anything else.

Once we have it in a more or less stable state this can be removed
completely.
This commit is contained in:
Abin 2023-02-06 13:42:38 +05:30 committed by Ashlie Martinez
parent 3edc931d44
commit 62d83d2df0
4 changed files with 29 additions and 2 deletions

View File

@ -81,6 +81,7 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command {
case createCommand:
c, fs = utils.AddCommand(cmd, oneDriveCreateCmd())
options.AddFeatureToggle(cmd, options.EnablePermissionsBackup())
options.AddFeatureToggle(cmd, options.EnableOneDriveDeltaIncrementals())
c.Use = c.Use + " " + oneDriveServiceCommandCreateUseSuffix
c.Example = oneDriveServiceCommandCreateExamples

View File

@ -16,6 +16,7 @@ func Control() control.Options {
opt.RestorePermissions = restorePermissions
opt.ToggleFeatures.DisableIncrementals = disableIncrementals
opt.ToggleFeatures.EnablePermissionsBackup = enablePermissionsBackup
opt.ToggleFeatures.EnableOneDriveDeltaIncrementals = enableOneDriveDeltaIncrentals
return opt
}
@ -57,8 +58,9 @@ func AddRestorePermissionsFlag(cmd *cobra.Command) {
// ---------------------------------------------------------------------------
var (
disableIncrementals bool
enablePermissionsBackup bool
disableIncrementals bool
enablePermissionsBackup bool
enableOneDriveDeltaIncrentals bool
)
type exposeFeatureFlag func(*pflag.FlagSet)
@ -97,3 +99,16 @@ func EnablePermissionsBackup() func(*pflag.FlagSet) {
cobra.CheckErr(fs.MarkHidden("enable-permissions-backup"))
}
}
// Adds the hidden '--enable-onedrive-delta-incrementals' cli flag which, when
// set, enables delta incrementals for OneDrive.
func EnableOneDriveDeltaIncrementals() func(*pflag.FlagSet) {
return func(fs *pflag.FlagSet) {
fs.BoolVar(
&enableOneDriveDeltaIncrentals,
"enable-onedrive-delta-incrementals",
false,
"Enables delta based incrementals for OneDrive")
cobra.CheckErr(fs.MarkHidden("enable-onedrive-delta-incrementals"))
}
}

View File

@ -289,6 +289,11 @@ func (op *BackupOperation) do(
// checker to see if conditions are correct for incremental backup behavior such as
// retrieving metadata like delta tokens and previous paths.
func useIncrementalBackup(sel selectors.Selector, opts control.Options) bool {
// TODO(meain): remove this once we stabilize delta incrementals for OneDrive
if sel.Service == selectors.ServiceOneDrive {
return opts.ToggleFeatures.EnableOneDriveDeltaIncrementals
}
// Delta-based incrementals currently only supported for Exchange
if sel.Service != selectors.ServiceExchange {
return false

View File

@ -80,4 +80,10 @@ type Toggles struct {
// permissions. Permission metadata increases graph api call count,
// so disabling their retrieval when not needed is advised.
EnablePermissionsBackup bool `json:"enablePermissionsBackup,omitempty"`
// EnableOneDriveDeltaIncrementals is used to enable OneDrive
// delta incrementals. It is set to false by default as OneDrive
// delta incrementals is still in development. This flag works
// independent of DisableIncrementals.
EnableOneDriveDeltaIncrementals bool `json:"enableOneDriveDeltaIncrementals,omitempty"`
}