Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

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

Nick Craig-Woodf9eb9c894de0
diff --git a/backend/mega/mega.go b/backend/mega/mega.go
index 0f0b7bb02..a75444149 100644
--- a/backend/mega/mega.go
+++ b/backend/mega/mega.go
@@ -39,8 +39,7 @@ const (
minSleep = 10 * time.Millisecond
maxSleep = 2 * time.Second
eventWaitTime = 500 * time.Millisecond
- decayConstant = 2 // bigger for slower decay, exponential
- useTrash = true // FIXME make configurable - rclone global
+ decayConstant = 2 // bigger for slower decay, exponential
)
var (
@@ -65,7 +64,12 @@ func init() {
IsPassword: true,
}, {
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,
Advanced: true,
}},
@@ -74,9 +78,10 @@ func init() {
// Options defines the configuration for this backend
type Options struct {
- User string `config:"user"`
- Pass string `config:"pass"`
- Debug bool `config:"debug"`
+ User string `config:"user"`
+ Pass string `config:"pass"`
+ Debug bool `config:"debug"`
+ HardDelete bool `config:"hard_delete"`
}
// Fs represents a remote mega
@@ -557,7 +562,7 @@ func (f *Fs) Mkdir(dir string) error {
// deleteNode removes a file or directory, observing useTrash
func (f *Fs) deleteNode(node *mega.Node) (err 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 err
diff --git a/docs/content/mega.md b/docs/content/mega.md
index a7a2135e6..a17db13bd 100644
--- a/docs/content/mega.md
+++ b/docs/content/mega.md
@@ -96,6 +96,23 @@ messages in the log about duplicates.
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 ###
This backend uses the [go-mega go