Browse Source

nextcloud: Fix WebDav propfind depth

pull/275/head
jld3103 2 years ago
parent
commit
b2ff970a5a
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 6
      packages/nextcloud/lib/src/webdav/client.dart
  2. 13
      packages/nextcloud/test/webdav.dart

6
packages/nextcloud/lib/src/webdav/client.dart

@ -213,11 +213,13 @@ class WebDavClient {
/// list the directories and files under given [remotePath]. /// list the directories and files under given [remotePath].
/// ///
/// Optionally populates the given [prop]s on the returned files. /// Optionally populates the given [prop]s on the returned files.
/// [depth] can be '0', '1' or 'infinity'.
Future<WebDavMultistatus> ls( Future<WebDavMultistatus> ls(
final String remotePath, { final String remotePath, {
final WebDavPropfindProp? prop, final WebDavPropfindProp? prop,
final int? depth, final String? depth,
}) async { }) async {
assert(depth == null || ['0', '1', 'infinity'].contains(depth), 'Depth has to be 0, 1 or infinity');
final response = await _send( final response = await _send(
'PROPFIND', 'PROPFIND',
_constructPath(remotePath), _constructPath(remotePath),
@ -231,7 +233,7 @@ class WebDavClient {
), ),
headers: { headers: {
if (depth != null) ...{ if (depth != null) ...{
'Depth': depth.toString(), 'Depth': depth,
}, },
}, },
); );

13
packages/nextcloud/test/webdav.dart

@ -55,6 +55,15 @@ Future run(final DockerImage image) async {
expect(props.ocsize, 50598); expect(props.ocsize, 50598);
}); });
test('List directory recursively', () async {
final responses = (await client.webdav.ls(
'/',
depth: 'infinity',
))
.responses;
expect(responses, hasLength(37));
});
test('Create directory', () async { test('Create directory', () async {
final response = await client.webdav.mkdir('test'); final response = await client.webdav.mkdir('test');
expect(response.statusCode, equals(201)); expect(response.statusCode, equals(201));
@ -229,7 +238,6 @@ Future run(final DockerImage image) async {
ocssharepermissions: true, ocssharepermissions: true,
ocmsharepermissions: true, ocmsharepermissions: true,
), ),
depth: 0,
)) ))
.responses .responses
.single .single
@ -276,7 +284,7 @@ Future run(final DockerImage image) async {
davgetlastmodified: true, davgetlastmodified: true,
ocsize: true, ocsize: true,
), ),
depth: 0, depth: '0',
)) ))
.responses .responses
.single .single
@ -339,7 +347,6 @@ Future run(final DockerImage image) async {
nccreationtime: true, nccreationtime: true,
ncuploadtime: true, ncuploadtime: true,
), ),
depth: 0,
)) ))
.responses .responses
.single .single

Loading…
Cancel
Save