-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nextcloud): Add low-level helpers for WebDavResponse #2561
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## test/nextcloud/all-props-parsed #2561 +/- ##
===================================================================
- Coverage 28.71% 28.71% -0.01%
===================================================================
Files 366 366
Lines 136274 136280 +6
===================================================================
Hits 39128 39128
- Misses 97146 97152 +6
*This pull request uses carry forward flags. Click here to find out more.
|
I was also thinking a lot about removing the webdav file abstraction and rather have something based on package:file in a separate repo. Is there a way we can do this without breaking the api? |
Sounds good, but the nextcloud package wouldn't know about this abstraction, right?
I need to get rid of this for CalDAV/CardDAV support, so if we deprecate it now we will have to wait a lot longer until we can support those as well. |
For the idea I head yes.
Then just duplicate the code and implement the new low level api separately. |
Signed-off-by: provokateurin <[email protected]>
Signed-off-by: provokateurin <[email protected]>
…pers Signed-off-by: provokateurin <[email protected]>
efc8823
to
81ab415
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we even keep the PathUri
abstraction or just make it work on strings?
/// Helpers for WebDavResponse | ||
extension WebDavResponseHelpers on WebDavResponse { | ||
/// All available props. | ||
WebDavProp get props => propstats.singleWhere((propstat) => propstat.status.contains('200 OK')).prop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the typical prop count on a file? How expensive is this operation?
The second commit calls file.props
multiple times subsequently.
I don't have any issue in keeping it like this and require the user to cache the prop themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are usually two propstats (one 200, one 404). This could also be changed to a firstWhere
to be slightly cheaper.
import 'package:nextcloud/src/api/webdav/models/models.dart'; | ||
|
||
/// Helpers for WebDavResponse | ||
extension WebDavResponseHelpers on WebDavResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just make these helpers available on the WebDavResponse
directly?
I understand that this will make the generation a bit harder, but it also allows us to cache these operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can give it a try. Caching is indeed a good reason to move it inline.
|
||
/// The path of the resource. | ||
PathUri get path { | ||
final href = PathUri.parse(Uri.decodeFull(this.href!)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the null assertion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be responses without a href which are not valid. Consumers need to filter these out (we already did in toWebDavFiles()
) and then we need to prevent null hrefs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this means that unfiltered responses will throw here.
I'd rather return a null
when there is no href
.
Then the filtering can be done based on the path
.
Necessary refactor for #718.
Extension helpers are still there to offload the small part of logic that is useful for consumers (while the rest was just proxy variables).