owncloud: add config owncloud_exclude_mounts which allows to exclude mounted folders when listing remote resources

This commit is contained in:
Thomas Müller 2024-03-12 11:55:36 +01:00 committed by Nick Craig-Wood
parent ca903b9872
commit c7bfadd10a

View File

@ -154,6 +154,11 @@ Set to 0 to disable chunked uploading.
Help: "Exclude ownCloud shares", Help: "Exclude ownCloud shares",
Advanced: true, Advanced: true,
Default: false, Default: false,
}, {
Name: "owncloud_exclude_mounts",
Help: "Exclude ownCloud mounted storages",
Advanced: true,
Default: false,
}}, }},
}) })
} }
@ -171,6 +176,7 @@ type Options struct {
PacerMinSleep fs.Duration `config:"pacer_min_sleep"` PacerMinSleep fs.Duration `config:"pacer_min_sleep"`
ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"` ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"`
ExcludeShares bool `config:"owncloud_exclude_shares"` ExcludeShares bool `config:"owncloud_exclude_shares"`
ExcludeMounts bool `config:"owncloud_exclude_mounts"`
} }
// Fs represents a remote webdav // Fs represents a remote webdav
@ -805,10 +811,17 @@ func (f *Fs) listAll(ctx context.Context, dir string, directoriesOnly bool, file
} }
} }
if f.opt.ExcludeShares { if f.opt.ExcludeShares {
// https: //owncloud.dev/apis/http/webdav/#supported-webdav-properties
if strings.Contains(item.Props.Permissions, "S") { if strings.Contains(item.Props.Permissions, "S") {
continue continue
} }
} }
if f.opt.ExcludeMounts {
// https: //owncloud.dev/apis/http/webdav/#supported-webdav-properties
if strings.Contains(item.Props.Permissions, "M") {
continue
}
}
// item.Name = restoreReservedChars(item.Name) // item.Name = restoreReservedChars(item.Name)
if fn(remote, isDir, &item.Props) { if fn(remote, isDir, &item.Props) {
found = true found = true