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

drive: implement cleanup (empty trash) - addresses #575

ishuah91dd975ab00d92
diff --git a/docs/content/drive.md b/docs/content/drive.md
index 066d6bc83..1a5028ce3 100644
--- a/docs/content/drive.md
+++ b/docs/content/drive.md
@@ -62,9 +62,9 @@ Choose a number from below, or type in your own value
\ "yandex"
Storage> 8
Google Application Client Id - leave blank normally.
-client_id>
+client_id>
Google Application Client Secret - leave blank normally.
-client_secret>
+client_secret>
Remote config
Use auto config?
* Say Y if not sure
@@ -82,8 +82,8 @@ n) No
y/n> n
--------------------
[remote]
-client_id =
-client_secret =
+client_id =
+client_secret =
token = {"AccessToken":"xxxx.x.xxxxx_xxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","RefreshToken":"1/xxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx","Expiry":"2014-03-16T13:57:58.955387075Z","Extra":null}
--------------------
y) Yes this is OK
@@ -140,8 +140,8 @@ Choose a number from below, or type in your own value
Enter a Team Drive ID> 1
--------------------
[remote]
-client_id =
-client_secret =
+client_id =
+client_secret =
token = {"AccessToken":"xxxx.x.xxxxx_xxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","RefreshToken":"1/xxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx","Expiry":"2014-03-16T13:57:58.955387075Z","Extra":null}
team_drive = xxxxxxxxxxxxxxxxxxxx
--------------------
@@ -173,6 +173,12 @@ By default rclone will delete files permanently when requested. If
sending them to the trash is required instead then use the
`--drive-use-trash` flag.
+### Emptying trash ###
+
+If you wish to empty your trash you can use the `rclone cleanup remote:`
+command which will permanently delete all your trashed files. This command
+does not take any path arguments.
+
### Specific options ###
Here are the command line options specific to this cloud storage
diff --git a/docs/content/overview.md b/docs/content/overview.md
index f95a65145..95bc2dab2 100644
--- a/docs/content/overview.md
+++ b/docs/content/overview.md
@@ -124,7 +124,7 @@ operations more efficient.
| Dropbox | Yes | Yes | Yes | Yes | No [#575](https://github.com/ncw/rclone/issues/575) | No | Yes |
| FTP | No | No | Yes | Yes | No | No | Yes |
| Google Cloud Storage | Yes | Yes | No | No | No | Yes | No [#1614](https://github.com/ncw/rclone/issues/1614) |
-| Google Drive | Yes | Yes | Yes | Yes | No [#575](https://github.com/ncw/rclone/issues/575) | No | Yes |
+| Google Drive | Yes | Yes | Yes | Yes | Yes | No | Yes |
| HTTP | No | No | No | No | No | No | No |
| Hubic | Yes † | Yes | No | No | No | Yes | No [#1614](https://github.com/ncw/rclone/issues/1614) |
| Microsoft Azure Blob Storage | Yes | Yes | No | No | No | Yes | No |
diff --git a/drive/drive.go b/drive/drive.go
index 8841920ca..04ded87f3 100644
--- a/drive/drive.go
+++ b/drive/drive.go
@@ -905,6 +905,19 @@ func (f *Fs) Purge() error {
return nil
}
+// CleanUp empties the trash
+func (f *Fs) CleanUp() error {
+ err := f.pacer.Call(func() (bool, error) {
+ err := f.svc.Files.EmptyTrash().Do()
+ return shouldRetry(err)
+ })
+
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
// Move src to this remote using server side move operations.
//
// This is stored with the remote path given
diff --git a/drive/drive_internal_test.go b/drive/drive_internal_test.go
index 016dee340..9184c5dff 100644
--- a/drive/drive_internal_test.go
+++ b/drive/drive_internal_test.go
@@ -3,9 +3,10 @@ package drive
import (
"testing"
+ "google.golang.org/api/drive/v2"
+
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
- "google.golang.org/api/drive/v2"
)
func TestInternalParseExtensions(t *testing.T) {