Skip to content

Commit e76414d

Browse files
author
David Christofas
committed
fix versions order in propfind response
1 parent 6494cac commit e76414d

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

changelog/unreleased/sort-versions.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: Fix version order in propfind responses
2+
3+
The order of the file versions in propfind responses was incorrect.
4+
5+
https://github.com/cs3org/reva/pull/1911

internal/http/services/owncloud/ocdav/versions.go

+16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"context"
2323
"net/http"
2424
"path"
25+
"sort"
2526

2627
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
2728
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
@@ -131,6 +132,7 @@ func (h *VersionsHandler) doListVersions(w http.ResponseWriter, r *http.Request,
131132
Type: provider.ResourceType_RESOURCE_TYPE_CONTAINER,
132133
})
133134

135+
sort.Sort(descendingMtime(versions))
134136
for i := range versions {
135137
vi := &provider.ResourceInfo{
136138
// TODO(jfd) we cannot access version content, this will be a problem when trying to fetch version thumbnails
@@ -203,3 +205,17 @@ func (h *VersionsHandler) doRestore(w http.ResponseWriter, r *http.Request, s *s
203205
}
204206
w.WriteHeader(http.StatusNoContent)
205207
}
208+
209+
type descendingMtime []*provider.FileVersion
210+
211+
func (v descendingMtime) Len() int {
212+
return len(v)
213+
}
214+
215+
func (v descendingMtime) Less(i, j int) bool {
216+
return v[i].Mtime >= v[j].Mtime
217+
}
218+
219+
func (v descendingMtime) Swap(i, j int) {
220+
v[i], v[j] = v[j], v[i]
221+
}

tests/acceptance/expected-failures-on-OCIS-storage.md

-4
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ Basic file management like up and download, move, copy, properties, quota, trash
2323
#### [Implement Versions Feature for ocis storage](https://github.com/owncloud/product/issues/210)
2424
- [apiWebdavEtagPropagation2/restoreVersion.feature:10](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavEtagPropagation2/restoreVersion.feature#L10)
2525

26-
#### [Version count is 1 more than on oC10](https://github.com/owncloud/ocis/issues/1633)
27-
- [apiVersions/fileVersionsSharingToShares.feature:178](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L178)
28-
2926
#### [uploading with old-chunking does not work](https://github.com/owncloud/ocis/issues/1343)
3027
#### [remote.php/dav/uploads endpoint does not exist](https://github.com/owncloud/ocis/issues/1321)
3128
- [apiVersions/fileVersions.feature:15](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L15)
3229
- [apiVersions/fileVersions.feature:23](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L23)
3330
- [apiVersions/fileVersions.feature:36](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L36)
3431
- [apiVersions/fileVersions.feature:45](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L45)
3532
- [apiVersions/fileVersions.feature:88](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L88)
36-
- [apiVersions/fileVersions.feature:89](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L89)
3733
- [apiVersions/fileVersions.feature:93](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L93)
3834
- [apiVersions/fileVersions.feature:276](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L276)
3935
- [apiVersions/fileVersions.feature:347](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L347)

tests/acceptance/expected-failures-on-OWNCLOUD-storage.md

-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ The following scenarios fail on OWNCLOUD storage but not on OCIS storage:
4242
- [apiTrashbinRestore/trashbinRestore.feature:330](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiTrashbinRestore/trashbinRestore.feature#L330)
4343
- [apiWebdavOperations/listFiles.feature:182](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavOperations/listFiles.feature#L182)
4444

45-
#### [Version count is 1 more than on oC10](https://github.com/owncloud/ocis/issues/1633)
46-
- [apiVersions/fileVersionsSharingToShares.feature:178](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L178)
47-
4845
#### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261)
4946
- [apiVersions/fileVersions.feature:420](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L420)
5047
- [apiVersions/fileVersions.feature:438](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L438)
@@ -57,7 +54,6 @@ The following scenarios fail on OWNCLOUD storage but not on OCIS storage:
5754
- [apiVersions/fileVersions.feature:36](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L36)
5855
- [apiVersions/fileVersions.feature:45](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L45)
5956
- [apiVersions/fileVersions.feature:88](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L88)
60-
- [apiVersions/fileVersions.feature:89](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L89)
6157
- [apiVersions/fileVersions.feature:93](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L93)
6258
- [apiVersions/fileVersions.feature:276](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L276)
6359
- [apiVersions/fileVersions.feature:347](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L347)

tests/acceptance/expected-failures-on-S3NG-storage.md

-7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ Basic file management like up and download, move, copy, properties, quota, trash
2020
- [apiTrashbinRestore/trashbinRestore.feature:309](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiTrashbin/trashbinRestore.feature#L309)
2121
- [apiTrashbinRestore/trashbinRestore.feature:310](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiTrashbin/trashbinRestore.feature#L310)
2222

23-
#### [Version count is 1 more than on oC10](https://github.com/owncloud/ocis/issues/1633)
24-
- [apiVersions/fileVersionsSharingToShares.feature:178](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L178)
25-
2623
#### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261)
2724
- [apiVersions/fileVersions.feature:420](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L420)
2825
- [apiVersions/fileVersions.feature:438](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L438)
@@ -38,7 +35,6 @@ Basic file management like up and download, move, copy, properties, quota, trash
3835
- [apiVersions/fileVersions.feature:36](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L36)
3936
- [apiVersions/fileVersions.feature:45](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L45)
4037
- [apiVersions/fileVersions.feature:88](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L88)
41-
- [apiVersions/fileVersions.feature:89](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L89)
4238
- [apiVersions/fileVersions.feature:93](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L93)
4339
- [apiVersions/fileVersions.feature:276](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L276)
4440
- [apiVersions/fileVersions.feature:347](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersions.feature#L347)
@@ -917,9 +913,6 @@ Scenario Outline: Renaming a file to a path with extension .part should not be p
917913
- [apiVersions/fileVersionsSharingToShares.feature:249](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L249)
918914
- [apiVersions/fileVersionsSharingToShares.feature:250](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L250)
919915

920-
#### [Version count is 1 more than on oC10](https://github.com/owncloud/ocis/issues/1633)
921-
- [apiVersions/fileVersionsSharingToShares.feature:178](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L178)
922-
923916
####[not possible to move file into a received folder](https://github.com/owncloud/ocis/issues/764)
924917
- [apiVersions/fileVersionsSharingToShares.feature:221](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L221)
925918
- [apiVersions/fileVersionsSharingToShares.feature:222](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature#L222)

0 commit comments

Comments
 (0)