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

This commit is contained in:
ishuah91 2017-09-01 20:54:14 +03:00 committed by Nick Craig-Wood
parent 2944f7603d
commit dd975ab00d
4 changed files with 28 additions and 8 deletions

View file

@ -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 sending them to the trash is required instead then use the
`--drive-use-trash` flag. `--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 ### ### Specific options ###
Here are the command line options specific to this cloud storage Here are the command line options specific to this cloud storage

View file

@ -124,7 +124,7 @@ operations more efficient.
| Dropbox | Yes | Yes | Yes | Yes | No [#575](https://github.com/ncw/rclone/issues/575) | No | Yes | | Dropbox | Yes | Yes | Yes | Yes | No [#575](https://github.com/ncw/rclone/issues/575) | No | Yes |
| FTP | No | No | Yes | Yes | No | 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 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 | | HTTP | No | No | No | No | No | No | No |
| Hubic | Yes † | Yes | No | No | No | Yes | No [#1614](https://github.com/ncw/rclone/issues/1614) | | 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 | | Microsoft Azure Blob Storage | Yes | Yes | No | No | No | Yes | No |

View file

@ -905,6 +905,19 @@ func (f *Fs) Purge() error {
return nil 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. // Move src to this remote using server side move operations.
// //
// This is stored with the remote path given // This is stored with the remote path given

View file

@ -3,9 +3,10 @@ package drive
import ( import (
"testing" "testing"
"google.golang.org/api/drive/v2"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"google.golang.org/api/drive/v2"
) )
func TestInternalParseExtensions(t *testing.T) { func TestInternalParseExtensions(t *testing.T) {