From 99b9062551dfbd15ed8e4d1d8b1ae48199545e12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?=
<1005065+DeepDiver1975@users.noreply.github.com>
Date: Thu, 12 Oct 2023 15:51:11 +0200
Subject: [PATCH] owncloud: add config `owncloud_exclude_shares` which allows
to exclude shared files and folders when listing remote resources
---
backend/webdav/api/types.go | 1 +
backend/webdav/webdav.go | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/backend/webdav/api/types.go b/backend/webdav/api/types.go
index 50feae106..f26f40e65 100644
--- a/backend/webdav/api/types.go
+++ b/backend/webdav/api/types.go
@@ -75,6 +75,7 @@ type Prop struct {
Size int64 `xml:"DAV: prop>getcontentlength,omitempty"`
Modified Time `xml:"DAV: prop>getlastmodified,omitempty"`
Checksums []string `xml:"prop>checksums>checksum,omitempty"`
+ Permissions string `xml:"prop>permissions,omitempty"`
MESha1Hex *string `xml:"ME: prop>sha1hex,omitempty"` // Fastmail-specific sha1 checksum
}
diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
index e8f83f66a..a2ef372c0 100644
--- a/backend/webdav/webdav.go
+++ b/backend/webdav/webdav.go
@@ -149,6 +149,11 @@ Set to 0 to disable chunked uploading.
`,
Advanced: true,
Default: 10 * fs.Mebi, // Default NextCloud `max_chunk_size` is `10 MiB`. See https://github.com/nextcloud/server/blob/0447b53bda9fe95ea0cbed765aa332584605d652/apps/files/lib/App.php#L57
+ }, {
+ Name: "owncloud_exclude_shares",
+ Help: "Exclude ownCloud shares",
+ Advanced: true,
+ Default: false,
}},
})
}
@@ -165,6 +170,7 @@ type Options struct {
Headers fs.CommaSepList `config:"headers"`
PacerMinSleep fs.Duration `config:"pacer_min_sleep"`
ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"`
+ ExcludeShares bool `config:"owncloud_exclude_shares"`
}
// Fs represents a remote webdav
@@ -702,6 +708,7 @@ var owncloudProps = []byte(`
+
`)
@@ -797,6 +804,11 @@ func (f *Fs) listAll(ctx context.Context, dir string, directoriesOnly bool, file
continue
}
}
+ if f.opt.ExcludeShares {
+ if strings.Contains(item.Props.Permissions, "S") {
+ continue
+ }
+ }
// item.Name = restoreReservedChars(item.Name)
if fn(remote, isDir, &item.Props) {
found = true