Browse Source

fix(nextcloud): Fix WebDAV progress

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/584/head
jld3103 1 year ago
parent
commit
a545b8003f
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/nextcloud/lib/src/webdav/client.dart
  2. 2
      packages/nextcloud/test/webdav_test.dart

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

@ -187,7 +187,7 @@ class WebDavClient {
return putStream( return putStream(
file.openRead().map((final chunk) { file.openRead().map((final chunk) {
uploaded += chunk.length; uploaded += chunk.length;
onProgress?.call(uploaded / fileStat.size * 100); onProgress?.call(uploaded / fileStat.size);
return Uint8List.fromList(chunk); return Uint8List.fromList(chunk);
}), }),
path, path,
@ -221,7 +221,7 @@ class WebDavClient {
response.listen((final chunk) async { response.listen((final chunk) async {
sink.add(chunk); sink.add(chunk);
downloaded += chunk.length; downloaded += chunk.length;
onProgress?.call(downloaded / response.contentLength * 100); onProgress?.call(downloaded / response.contentLength);
if (downloaded >= response.contentLength) { if (downloaded >= response.contentLength) {
completer.complete(); completer.complete();
} }

2
packages/nextcloud/test/webdav_test.dart

@ -301,7 +301,7 @@ void main() {
destination, destination,
onProgress: progressValues.add, onProgress: progressValues.add,
); );
expect(progressValues, containsAll([100.0, 100.0])); expect(progressValues, containsAll([1.0, 1.0]));
expect(destination.readAsBytesSync(), source.readAsBytesSync()); expect(destination.readAsBytesSync(), source.readAsBytesSync());
destinationDir.deleteSync(recursive: true); destinationDir.deleteSync(recursive: true);

Loading…
Cancel
Save