Skip to content

Commit

Permalink
fix aggregated child folder id (cs3org#2430)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Jan 10, 2022
1 parent 0b50ca9 commit 3d66054
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-aggregated-child-folder-id.md
Original file line number Diff line number Diff line change
@@ -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
11 changes: 8 additions & 3 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,23 +379,28 @@ 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 != "/" {
spaceInfo.Type = provider.ResourceType_RESOURCE_TYPE_CONTAINER
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")
}
Expand Down

0 comments on commit 3d66054

Please sign in to comment.