"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
drive: Add --drive-use-trash flag so rclone trashes instead of deletes - fixes #82
Nick Craig-Woodd8306938a121
diff --git a/docs/content/drive.md b/docs/content/drive.mdindex 61a64c8c9..7e16414d2 100644--- a/docs/content/drive.md+++ b/docs/content/drive.md@@ -85,6 +85,12 @@ was* They are deleted after 30 days or 100 revisions (whatever comes first).* They do not count towards a user storage quota.+### Deleting files ###++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.+### Limitations ###Drive has quite a lot of rate limiting. This causes rclone to bediff --git a/drive/drive.go b/drive/drive.goindex 7420fca37..ebce8fbc6 100644--- a/drive/drive.go+++ b/drive/drive.go@@ -39,6 +39,7 @@ const (var (// FlagsdriveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker.")+ driveUseTrash = pflag.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")// chunkSize is the size of the chunks created during a resumable upload and should be a power of two.// 1<<18 is the minimum size supported by the Google uploader, and there is no maximum.chunkSize = fs.SizeSuffix(256 * 1024)@@ -803,7 +804,11 @@ func (f *FsDrive) Rmdir() error {// Delete the directory if it isn't the rootif f.root != "" {f.call(&err, func() {- err = f.svc.Files.Delete(f.rootId).Do()+ if *driveUseTrash {+ _, err = f.svc.Files.Trash(f.rootId).Do()+ } else {+ err = f.svc.Files.Delete(f.rootId).Do()+ }})if err != nil {return err@@ -832,7 +837,11 @@ func (f *FsDrive) Purge() error {return err}f.call(&err, func() {- err = f.svc.Files.Delete(f.rootId).Do()+ if *driveUseTrash {+ _, err = f.svc.Files.Trash(f.rootId).Do()+ } else {+ err = f.svc.Files.Delete(f.rootId).Do()+ }})f.resetRoot()if err != nil {@@ -1023,7 +1032,11 @@ func (o *FsObjectDrive) Update(in io.Reader, modTime time.Time, size int64) errofunc (o *FsObjectDrive) Remove() error {var err erroro.drive.call(&err, func() {- err = o.drive.svc.Files.Delete(o.id).Do()+ if *driveUseTrash {+ _, err = o.drive.svc.Files.Trash(o.id).Do()+ } else {+ err = o.drive.svc.Files.Delete(o.id).Do()+ }})return err}