mega: add --mega-hard-delete flag - fixes #2409

This commit is contained in:
Nick Craig-Wood 2018-08-01 13:44:19 +01:00
parent f7a92f2c15
commit f9eb9c894d
2 changed files with 29 additions and 7 deletions

View File

@ -39,8 +39,7 @@ const (
minSleep = 10 * time.Millisecond minSleep = 10 * time.Millisecond
maxSleep = 2 * time.Second maxSleep = 2 * time.Second
eventWaitTime = 500 * time.Millisecond eventWaitTime = 500 * time.Millisecond
decayConstant = 2 // bigger for slower decay, exponential decayConstant = 2 // bigger for slower decay, exponential
useTrash = true // FIXME make configurable - rclone global
) )
var ( var (
@ -65,7 +64,12 @@ func init() {
IsPassword: true, IsPassword: true,
}, { }, {
Name: "debug", Name: "debug",
Help: "If set then output more debug from mega.", Help: "Output more debug from Mega.",
Default: false,
Advanced: true,
}, {
Name: "hard_delete",
Help: "Delete files permanently rather than putting them into the trash.",
Default: false, Default: false,
Advanced: true, Advanced: true,
}}, }},
@ -74,9 +78,10 @@ func init() {
// Options defines the configuration for this backend // Options defines the configuration for this backend
type Options struct { type Options struct {
User string `config:"user"` User string `config:"user"`
Pass string `config:"pass"` Pass string `config:"pass"`
Debug bool `config:"debug"` Debug bool `config:"debug"`
HardDelete bool `config:"hard_delete"`
} }
// Fs represents a remote mega // Fs represents a remote mega
@ -557,7 +562,7 @@ func (f *Fs) Mkdir(dir string) error {
// deleteNode removes a file or directory, observing useTrash // deleteNode removes a file or directory, observing useTrash
func (f *Fs) deleteNode(node *mega.Node) (err error) { func (f *Fs) deleteNode(node *mega.Node) (err error) {
err = f.pacer.Call(func() (bool, error) { err = f.pacer.Call(func() (bool, error) {
err = f.srv.Delete(node, !useTrash) err = f.srv.Delete(node, f.opt.HardDelete)
return shouldRetry(err) return shouldRetry(err)
}) })
return err return err

View File

@ -96,6 +96,23 @@ messages in the log about duplicates.
Use `rclone dedupe` to fix duplicated files. Use `rclone dedupe` to fix duplicated files.
### Specific options ###
Here are the command line options specific to this cloud storage
system.
#### --mega-debug ####
If this flag is set (along with `-vv`) it will print further debugging
information from the mega backend.
#### --mega-hard-delete ####
Normally the mega backend will put all deletions into the trash rather
than permanently deleting them. If you specify this flag (or set it
in the advanced config) then rclone will permanently delete objects
instead.
### Limitations ### ### Limitations ###
This backend uses the [go-mega go This backend uses the [go-mega go