From 3d66054767450bcf77068c1a4c9e6a4a7b11d0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 10 Jan 2022 17:30:01 +0100 Subject: [PATCH] fix aggregated child folder id (#2430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../unreleased/fix-aggregated-child-folder-id.md | 5 +++++ internal/http/services/owncloud/ocdav/propfind.go | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/fix-aggregated-child-folder-id.md diff --git a/changelog/unreleased/fix-aggregated-child-folder-id.md b/changelog/unreleased/fix-aggregated-child-folder-id.md new file mode 100644 index 0000000000..7387afc989 --- /dev/null +++ b/changelog/unreleased/fix-aggregated-child-folder-id.md @@ -0,0 +1,5 @@ +Bugfix: fix aggregated child folder id + +Propfind now returns the correct id and correctly aggregates the mtime and etag. + +https://github.com/cs3org/reva/pull/2430 \ No newline at end of file diff --git a/internal/http/services/owncloud/ocdav/propfind.go b/internal/http/services/owncloud/ocdav/propfind.go index d596f14008..cf7ebe3f93 100644 --- a/internal/http/services/owncloud/ocdav/propfind.go +++ b/internal/http/services/owncloud/ocdav/propfind.go @@ -379,7 +379,7 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht info.Path = path.Join(requestPath, info.Path) } resourceInfos = append(resourceInfos, res.Infos...) - case strings.HasPrefix(spaceInfo.Path, requestPath): // space is a child of the requested path + case strings.HasPrefix(spaceInfo.Path, requestPath): // space is a deep child of the requested path childPath := strings.TrimPrefix(spaceInfo.Path, requestPath) childName, tail := router.ShiftPath(childPath) if tail != "/" { @@ -387,15 +387,20 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht spaceInfo.Checksum = nil // TODO unset opaque checksum } - spaceInfo.Path = path.Join(requestPath, childName) if existingChild, ok := childInfos[childName]; ok { // use most recent child if existingChild.Mtime == nil || (spaceInfo.Mtime != nil && utils.TSToUnixNano(spaceInfo.Mtime) > utils.TSToUnixNano(existingChild.Mtime)) { - childInfos[childName] = spaceInfo + childInfos[childName].Mtime = spaceInfo.Mtime + childInfos[childName].Etag = spaceInfo.Etag + } + // only update fileid if the resource is a direct child + if tail == "/" { + childInfos[childName].Id = spaceInfo.Id } } else { childInfos[childName] = spaceInfo } + spaceInfo.Path = path.Join(requestPath, childName) default: log.Debug().Msg("unhandled") }