From 49816e67bdffca2fa4e9ab980900280c2ec231d3 Mon Sep 17 00:00:00 2001 From: ishuah91 Date: Thu, 7 Sep 2017 20:10:39 +0300 Subject: [PATCH] yandex: implement cleanup (empty trash) - addresses #575 --- docs/content/overview.md | 2 +- docs/content/yandex.md | 6 ++++++ yandex/api/empty_trash.go | 13 +++++++++++++ yandex/yandex.go | 5 +++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 yandex/api/empty_trash.go diff --git a/docs/content/overview.md b/docs/content/overview.md index 95bc2dab2..7af7d436f 100644 --- a/docs/content/overview.md +++ b/docs/content/overview.md @@ -132,7 +132,7 @@ operations more efficient. | Openstack Swift | Yes † | Yes | No | No | No | Yes | No [#1614](https://github.com/ncw/rclone/issues/1614) | | QingStor | No | Yes | No | No | No | Yes | No [#1614](https://github.com/ncw/rclone/issues/1614) | | SFTP | No | No | Yes | Yes | No | No | Yes | -| Yandex Disk | Yes | No | No | No | No [#575](https://github.com/ncw/rclone/issues/575) | Yes | Yes | +| Yandex Disk | Yes | No | No | No | Yes | Yes | Yes | | The local filesystem | Yes | No | Yes | Yes | No | No | Yes | ### Purge ### diff --git a/docs/content/yandex.md b/docs/content/yandex.md index 77e736986..91bff66fb 100644 --- a/docs/content/yandex.md +++ b/docs/content/yandex.md @@ -121,3 +121,9 @@ metadata called `rclone_modified` in RFC3339 with nanoseconds format. ### MD5 checksums ### MD5 checksums are natively supported by Yandex Disk. + +### 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. diff --git a/yandex/api/empty_trash.go b/yandex/api/empty_trash.go new file mode 100644 index 000000000..54d97377a --- /dev/null +++ b/yandex/api/empty_trash.go @@ -0,0 +1,13 @@ +package src + +// EmptyTrash will permanently delete all trashed files/folders from Yandex Disk +func (c *Client) EmptyTrash() error { + fullURL := RootAddr + fullURL += "/v1/disk/trash/resources" + + if err := c.PerformDelete(fullURL); err != nil { + return err + } + + return nil +} diff --git a/yandex/yandex.go b/yandex/yandex.go index 1cea449ce..f6a40f949 100644 --- a/yandex/yandex.go +++ b/yandex/yandex.go @@ -479,6 +479,11 @@ func (f *Fs) Purge() error { return f.purgeCheck("", false) } +// CleanUp permanently deletes all trashed files/folders +func (f *Fs) CleanUp() error { + return f.yd.EmptyTrash() +} + // Hashes returns the supported hash sets. func (f *Fs) Hashes() fs.HashSet { return fs.HashSet(fs.HashMD5)