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

jottacloud: implement cleanup

buengese64b5105edd07
diff --git a/backend/jottacloud/api/types.go b/backend/jottacloud/api/types.go
index fb28d39fa..06395f06a 100644
--- a/backend/jottacloud/api/types.go
+++ b/backend/jottacloud/api/types.go
@@ -164,6 +164,12 @@ type CustomerInfo struct {
IOSHash string `json:"ios_hash"`
}
+// TrashResponse is returned when emptying the Trash
+type TrashResponse struct {
+ Folders int64 `json:"folders"`
+ Files int64 `json:"files"`
+}
+
// XML structures returned by the old API
// Flag is a hacky type for checking if an attribute is present
diff --git a/backend/jottacloud/jottacloud.go b/backend/jottacloud/jottacloud.go
index 8c30d40f7..5422766ca 100644
--- a/backend/jottacloud/jottacloud.go
+++ b/backend/jottacloud/jottacloud.go
@@ -1064,6 +1064,22 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
return usage, nil
}
+// CleanUp empties the trash
+func (f *Fs) CleanUp(ctx context.Context) error {
+ opts := rest.Opts{
+ Method: "POST",
+ Path: "files/v1/purge_trash",
+ }
+
+ var info api.TrashResponse
+ _, err := f.apiSrv.CallJSON(ctx, &opts, nil, &info)
+ if err != nil {
+ return errors.Wrap(err, "couldn't empty trash")
+ }
+
+ return nil
+}
+
// Hashes returns the supported hash sets.
func (f *Fs) Hashes() hash.Set {
return hash.Set(hash.MD5)
@@ -1370,6 +1386,7 @@ var (
_ fs.ListRer = (*Fs)(nil)
_ fs.PublicLinker = (*Fs)(nil)
_ fs.Abouter = (*Fs)(nil)
+ _ fs.CleanUpper = (*Fs)(nil)
_ fs.Object = (*Object)(nil)
_ fs.MimeTyper = (*Object)(nil)
)