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

drime: implement About

Cohinem2bd6630c2eac
diff --git a/backend/drime/api/types.go b/backend/drime/api/types.go
index 0a1a8bab2..bebd38fae 100644
--- a/backend/drime/api/types.go
+++ b/backend/drime/api/types.go
@@ -235,3 +235,11 @@ type MultiPartAbort struct {
UploadID string `json:"uploadId"`
Key string `json:"key"`
}
+
+// SpaceUsageResponse is returned by GET /user/space-usage
+type SpaceUsageResponse struct {
+ Used int64 `json:"used"`
+ Available int64 `json:"available"`
+ Status string `json:"status"`
+ SEO any `json:"seo"`
+}
diff --git a/backend/drime/drime.go b/backend/drime/drime.go
index 8a199ab11..bfe475631 100644
--- a/backend/drime/drime.go
+++ b/backend/drime/drime.go
@@ -1344,6 +1344,37 @@ func (s *drimeChunkWriter) Abort(ctx context.Context) error {
return nil
}
+// About gets quota information
+func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
+ opts := rest.Opts{
+ Method: "GET",
+ Path: "/user/space-usage",
+ Parameters: url.Values{},
+ }
+ if f.opt.WorkspaceID != "" {
+ opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
+ }
+
+ var resp *http.Response
+ var result api.SpaceUsageResponse
+ var err error
+ err = f.pacer.Call(func() (bool, error) {
+ resp, err = f.srv.CallJSON(ctx, &opts, nil, &result)
+ return shouldRetry(ctx, resp, err)
+ })
+ if err != nil {
+ return nil, fmt.Errorf("failed to get Drime Quota: %w", err)
+ }
+
+ usage := &fs.Usage{
+ Total: fs.NewUsageValue(result.Available),
+ Used: fs.NewUsageValue(result.Used),
+ Free: fs.NewUsageValue(result.Available - result.Used),
+ }
+
+ return usage, nil
+}
+
// ------------------------------------------------------------
// Fs returns the parent Fs
@@ -1555,6 +1586,7 @@ var (
_ fs.Mover = (*Fs)(nil)
_ fs.DirMover = (*Fs)(nil)
_ fs.DirCacheFlusher = (*Fs)(nil)
+ _ fs.Abouter = (*Fs)(nil)
_ fs.OpenChunkWriter = (*Fs)(nil)
_ fs.Object = (*Object)(nil)
_ fs.IDer = (*Object)(nil)
diff --git a/docs/data/backends/drime.yaml b/docs/data/backends/drime.yaml
index 9303a0473..fa5c40997 100644
--- a/docs/data/backends/drime.yaml
+++ b/docs/data/backends/drime.yaml
@@ -12,6 +12,7 @@ security: High
virtual: false
remote: 'TestDrime:'
features:
+- About
- CanHaveEmptyDirectories
- Copy
- DirCacheFlush