Skip to content

Commit e3e0d22

Browse files
authored
make delete path a Stream response (#1540)
1 parent 4e3a4f3 commit e3e0d22

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

sdk/storage_datalake/src/operations/path_delete.rs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::clients::PathClient;
22
use crate::request_options::*;
3-
use azure_core::{prelude::*, Request};
3+
use azure_core::{prelude::*, Pageable, Request};
44
use azure_core::{AppendToUrlQuery, Response as HttpResponse};
55
use azure_storage::headers::CommonStorageResponseHeaders;
66
use std::convert::TryInto;
@@ -15,27 +15,29 @@ operation! {
1515
}
1616

1717
impl<C: PathClient + 'static> DeletePathBuilder<C> {
18-
pub fn into_future(self) -> DeletePath {
19-
Box::pin(async move {
20-
let mut url = self.client.url()?;
18+
pub fn into_stream(self) -> Pageable<DeletePathResponse, azure_core::error::Error> {
19+
let make_request = move |continuation: Option<NextMarker>| {
20+
let this = self.clone();
21+
let mut ctx = self.context.clone();
2122

22-
if let Some(continuation) = self.continuation {
23-
continuation.append_to_url_query_as_continuation(&mut url);
24-
};
25-
self.recursive.append_to_url_query(&mut url);
23+
async move {
24+
let mut url = this.client.url()?;
2625

27-
let mut request = Request::new(url, azure_core::Method::Delete);
26+
let continuation = continuation.or_else(|| this.continuation.clone());
27+
if let Some(continuation) = continuation {
28+
continuation.append_to_url_query_as_continuation(&mut url);
29+
};
30+
this.recursive.append_to_url_query(&mut url);
2831

29-
request.insert_headers(&self.if_match_condition);
30-
request.insert_headers(&self.if_modified_since);
32+
let mut request = Request::new(url, azure_core::Method::Delete);
3133

32-
let response = self
33-
.client
34-
.send(&mut self.context.clone(), &mut request)
35-
.await?;
36-
37-
DeletePathResponse::try_from(response).await
38-
})
34+
request.insert_headers(&this.if_match_condition);
35+
request.insert_headers(&this.if_modified_since);
36+
let response = this.client.send(&mut ctx, &mut request).await?;
37+
DeletePathResponse::try_from(response).await
38+
}
39+
};
40+
Pageable::new(make_request)
3941
}
4042
}
4143

@@ -55,3 +57,10 @@ impl DeletePathResponse {
5557
})
5658
}
5759
}
60+
61+
impl Continuable for DeletePathResponse {
62+
type Continuation = NextMarker;
63+
fn continuation(&self) -> Option<Self::Continuation> {
64+
self.continuation.clone()
65+
}
66+
}

sdk/storage_datalake/tests/files.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use azure_storage_datalake::Properties;
2+
use futures::StreamExt;
23
use std::{assert_eq, assert_ne};
34

45
mod setup;
@@ -32,7 +33,10 @@ async fn file_create_delete() -> azure_core::Result<()> {
3233

3334
file_client.create().await?;
3435

35-
file_client.delete().await?;
36+
let mut stream = file_client.delete().into_stream();
37+
while let Some(result) = stream.next().await {
38+
result?;
39+
}
3640

3741
file_system_client.delete().await?;
3842

0 commit comments

Comments
 (0)