From 11c6489fd1bc466018c3270488bf23338236f68d Mon Sep 17 00:00:00 2001 From: Oksana Zhykina Date: Mon, 5 Feb 2024 15:37:21 +0200 Subject: [PATCH] quatrix: add option to skip project folders --- backend/quatrix/api/types.go | 10 ++++++++++ backend/quatrix/quatrix.go | 17 ++++++++++++++++- docs/content/quatrix.md | 24 +++++++++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/backend/quatrix/api/types.go b/backend/quatrix/api/types.go index 0a55f5e60..7930fe4d3 100644 --- a/backend/quatrix/api/types.go +++ b/backend/quatrix/api/types.go @@ -104,6 +104,16 @@ func (f *File) IsDir() bool { return f.Type == "D" || f.Type == "S" || f.Type == "T" } +// IsProjectFolder returns true if object is a project folder +// false otherwise +func (f *File) IsProjectFolder() bool { + if f == nil { + return false + } + + return f.Type == "S" +} + // SetMTimeParams is the request to set modification time for object type SetMTimeParams struct { ID string `json:"id,omitempty"` diff --git a/backend/quatrix/quatrix.go b/backend/quatrix/quatrix.go index e615ac49e..91d8c69d9 100644 --- a/backend/quatrix/quatrix.go +++ b/backend/quatrix/quatrix.go @@ -89,7 +89,13 @@ func init() { }, { Name: "hard_delete", - Help: "Delete files permanently rather than putting them into the trash.", + Help: "Delete files permanently rather than putting them into the trash", + Advanced: true, + Default: false, + }, + { + Name: "skip_project_folders", + Help: "Skip project folders in operations", Advanced: true, Default: false, }, @@ -106,6 +112,7 @@ type Options struct { MinimalChunkSize fs.SizeSuffix `config:"minimal_chunk_size"` MaximalSummaryChunkSize fs.SizeSuffix `config:"maximal_summary_chunk_size"` HardDelete bool `config:"hard_delete"` + SkipProjectFolders bool `config:"skip_project_folders"` } // Fs represents remote Quatrix fs @@ -376,6 +383,10 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e } for _, file := range folder.Content { + if f.skipFile(&file) { + continue + } + remote := path.Join(dir, f.opt.Enc.ToStandardName(file.Name)) if file.IsDir() { f.dirCache.Put(remote, file.ID) @@ -401,6 +412,10 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e return entries, nil } +func (f *Fs) skipFile(file *api.File) bool { + return f.opt.SkipProjectFolders && file.IsProjectFolder() +} + // NewObject finds the Object at remote. If it can't be found // it returns the error fs.ErrorObjectNotFound. func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) { diff --git a/docs/content/quatrix.md b/docs/content/quatrix.md index bc8d715fd..5a89f06b3 100644 --- a/docs/content/quatrix.md +++ b/docs/content/quatrix.md @@ -227,7 +227,7 @@ Properties: #### --quatrix-hard-delete -Delete files permanently rather than putting them into the trash. +Delete files permanently rather than putting them into the trash Properties: @@ -236,6 +236,28 @@ Properties: - Type: bool - Default: false +#### --quatrix-skip-project-folders + +Skip project folders in operations + +Properties: + +- Config: skip_project_folders +- Env Var: RCLONE_QUATRIX_SKIP_PROJECT_FOLDERS +- Type: bool +- Default: false + +#### --quatrix-description + +Description of the remote + +Properties: + +- Config: description +- Env Var: RCLONE_QUATRIX_DESCRIPTION +- Type: string +- Required: false + {{< rem autogenerated options stop >}} ## Storage usage