Skip to content

simplify HeadPathResponse try_from #2

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions sdk/storage_datalake/src/operations/path_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,17 @@ pub struct HeadPathResponse {
pub common_storage_response_headers: CommonStorageResponseHeaders,
pub etag: String,
pub last_modified: DateTime<Utc>,
pub properties: Option<Properties>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Cameron, thanks for the response!

This needs to be an Option because Properties, in this context, is equal to x-ms-properties, and this header only gets returned when you don't specify an action. See the docs here. The previous implementation didn't consider it optional because GetProperties was the only implementation that existed. However, to support GetStatus (a derivation of GetProperties), it will need to be optional to support both. Hence the reason for changing this to an Option. Without this, the API response cannot be processed correctly. Take a look at the test I wrote for this function for context, specifically here and here. You will see that when the action is GetStatus, that x-ms-properties is not returned.

pub properties: Properties,
}

impl HeadPathResponse {
pub async fn try_from(response: HttpResponse) -> Result<Self, crate::Error> {
let (_status_code, headers, _pinned_stream) = response.deconstruct();

let headers = response.headers();
Ok(Self {
common_storage_response_headers: (&headers).try_into()?,
etag: etag_from_headers(&headers)?,
last_modified: last_modified_from_headers(&headers)?,
properties: (&headers).try_into().ok(),
common_storage_response_headers: headers.try_into()?,
etag: etag_from_headers(headers)?,
last_modified: last_modified_from_headers(headers)?,
properties: headers.try_into()?,
})
}
}