quatrix: add option to skip project folders

This commit is contained in:
Oksana Zhykina 2024-02-05 15:37:21 +02:00 committed by Nick Craig-Wood
parent 43823bc925
commit 11c6489fd1
3 changed files with 49 additions and 2 deletions

View file

@ -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"`

View file

@ -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) {

View file

@ -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