From 25f5ff78f5ee182c67f00d010a2f6d06929c0a2d Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 31 Jul 2023 13:05:48 +0200 Subject: [PATCH] refactor(nextcloud): Rename WebDAV path variables --- packages/nextcloud/lib/src/webdav/client.dart | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/nextcloud/lib/src/webdav/client.dart b/packages/nextcloud/lib/src/webdav/client.dart index e3bf1c9a..0673454e 100644 --- a/packages/nextcloud/lib/src/webdav/client.dart +++ b/packages/nextcloud/lib/src/webdav/client.dart @@ -91,9 +91,9 @@ class WebDavClient { ); } - /// make a dir with [remotePath] under current dir + /// make a dir with [path] under current dir Future mkdir( - final String remotePath, { + final String path, { final bool safe = true, }) async { final expectedCodes = [ @@ -105,21 +105,21 @@ class WebDavClient { ]; return _send( 'MKCOL', - _constructPath(remotePath), + _constructPath(path), expectedCodes, ); } /// just like mkdir -p Future mkdirs( - final String remotePath, { + final String path, { final bool safe = true, }) async { - final dirs = remotePath.trim().split('/')..removeWhere((final value) => value == ''); + final dirs = path.trim().split('/')..removeWhere((final value) => value == ''); if (dirs.isEmpty) { return null; } - if (remotePath.trim().startsWith('/')) { + if (path.trim().startsWith('/')) { dirs[0] = '/${dirs[0]}'; // coverage:ignore-line } final prevPath = StringBuffer(); @@ -161,32 +161,32 @@ class WebDavClient { return headers.isNotEmpty ? headers : null; } - /// upload a new file with [localData] as content to [remotePath] + /// upload a new file with [localData] as content to [path] Future upload( final Uint8List localData, - final String remotePath, { + final String path, { final DateTime? lastModified, final DateTime? created, }) => uploadStream( Stream.value(localData), - remotePath, + path, lastModified: lastModified, created: created, contentLength: localData.lengthInBytes, ); - /// upload a new file with [localData] as content to [remotePath] + /// upload a new file with [localData] as content to [path] Future uploadStream( final Stream localData, - final String remotePath, { + final String path, { final DateTime? lastModified, final DateTime? created, final int? contentLength, }) async => _send( 'PUT', - _constructPath(remotePath), + _constructPath(path), [200, 201, 204], data: localData, headers: _generateUploadHeaders( @@ -196,32 +196,32 @@ class WebDavClient { ), ); - /// download [remotePath] and store the response file contents to String - Future download(final String remotePath) async => (await downloadStream(remotePath)).bodyBytes; + /// download [path] and store the response file contents to String + Future download(final String path) async => (await downloadStream(path)).bodyBytes; - /// download [remotePath] and store the response file contents to ByteStream - Future downloadStream(final String remotePath) async => _send( + /// download [path] and store the response file contents to ByteStream + Future downloadStream(final String path) async => _send( 'GET', - _constructPath(remotePath), + _constructPath(path), [200], ); Future _parseResponse(final HttpClientResponse response) async => WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.body).rootElement); - /// list the directories and files under given [remotePath]. + /// list the directories and files under given [path]. /// /// Optionally populates the given [prop]s on the returned files. /// [depth] can be '0', '1' or 'infinity'. Future ls( - final String remotePath, { + final String path, { final WebDavPropfindProp? prop, 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), + _constructPath(path), [207, 301], data: Stream.value( Uint8List.fromList( @@ -249,17 +249,17 @@ class WebDavClient { } /// Runs the filter-files report with the given [filterRules] on the - /// [remotePath]. + /// [path]. /// /// Optionally populates the given [prop]s on the returned files. Future filter( - final String remotePath, + final String path, final WebDavOcFilterRules filterRules, { final WebDavPropfindProp? prop, }) async { final response = await _send( 'REPORT', - _constructPath(remotePath), + _constructPath(path), [200, 207], data: Stream.value( Uint8List.fromList( @@ -275,16 +275,16 @@ class WebDavClient { return _parseResponse(response); } - /// Update (string) properties of the given [remotePath]. + /// Update (string) properties of the given [path]. /// /// Returns true if the update was successful. Future updateProps( - final String remotePath, + final String path, final WebDavProp prop, ) async { final response = await _send( 'PROPPATCH', - _constructPath(remotePath), + _constructPath(path), [200, 207], data: Stream.value( Uint8List.fromList(