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].
///
/// Optionally populates the given [prop]s on the returned files.
/// [depth] can be '0', '1' or 'infinity'.
Future<WebDavMultistatus> ls(
final String remotePath, {
final WebDavPropfindProp? prop,
final int? depth,
final String? depth,
}) async {
assert(depth == null || ['0', '1', 'infinity'].contains(depth), 'Depth has to be 0, 1 or infinity');
final response = await _send(
'PROPFIND',
_constructPath(remotePath),
@ -231,7 +233,7 @@ class WebDavClient {
),
headers: {
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);
});
test('List directory recursively', () async {
final responses = (await client.webdav.ls(
'/',
depth: 'infinity',
))
.responses;
expect(responses, hasLength(37));
});
test('Create directory', () async {
final response = await client.webdav.mkdir('test');
expect(response.statusCode, equals(201));
@ -229,7 +238,6 @@ Future run(final DockerImage image) async {
ocssharepermissions: true,
ocmsharepermissions: true,
),
depth: 0,
))
.responses
.single
@ -276,7 +284,7 @@ Future run(final DockerImage image) async {
davgetlastmodified: true,
ocsize: true,
),
depth: 0,
depth: '0',
))
.responses
.single
@ -339,7 +347,6 @@ Future run(final DockerImage image) async {
nccreationtime: true,
ncuploadtime: true,
),
depth: 0,
))
.responses
.single

Loading…
Cancel
Save