onedrive: add --onedrive-hard-delete to permanently delete files

Fixes #7812
This commit is contained in:
Nick Craig-Wood 2024-05-14 12:40:17 +01:00
parent 7c0645dda9
commit 51aca9cf9d

View File

@ -241,6 +241,18 @@ modification time and removes all but the last version.
this flag there. this flag there.
`, `,
Advanced: true, Advanced: true,
}, {
Name: "hard_delete",
Help: `Permanently delete files on removal.
Normally files will get sent to the recycle bin on deletion. Setting
this flag causes them to be permanently deleted. Use with care.
OneDrive personal accounts do not support the permanentDelete API,
it only applies to OneDrive for Business and SharePoint document libraries.
`,
Advanced: true,
Default: false,
}, { }, {
Name: "link_scope", Name: "link_scope",
Default: "anonymous", Default: "anonymous",
@ -695,6 +707,7 @@ type Options struct {
ServerSideAcrossConfigs bool `config:"server_side_across_configs"` ServerSideAcrossConfigs bool `config:"server_side_across_configs"`
ListChunk int64 `config:"list_chunk"` ListChunk int64 `config:"list_chunk"`
NoVersions bool `config:"no_versions"` NoVersions bool `config:"no_versions"`
HardDelete bool `config:"hard_delete"`
LinkScope string `config:"link_scope"` LinkScope string `config:"link_scope"`
LinkType string `config:"link_type"` LinkType string `config:"link_type"`
LinkPassword string `config:"link_password"` LinkPassword string `config:"link_password"`
@ -1479,7 +1492,12 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
// deleteObject removes an object by ID // deleteObject removes an object by ID
func (f *Fs) deleteObject(ctx context.Context, id string) error { func (f *Fs) deleteObject(ctx context.Context, id string) error {
opts := f.newOptsCall(id, "DELETE", "") var opts rest.Opts
if f.opt.HardDelete {
opts = f.newOptsCall(id, "POST", "/permanentDelete")
} else {
opts = f.newOptsCall(id, "DELETE", "")
}
opts.NoResponse = true opts.NoResponse = true
return f.pacer.Call(func() (bool, error) { return f.pacer.Call(func() (bool, error) {