Skip to content

Commit ed809be

Browse files
committed
feat(services/b2): Add operation in http context
1 parent 9c1155c commit ed809be

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core/src/services/b2/core.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ impl B2Core {
154154
req = req.header(header::RANGE, range.to_header());
155155
}
156156

157+
let req = req.extension(Operation::Read);
158+
157159
let req = req.body(Buffer::new()).map_err(new_request_build_error)?;
158160

159161
self.info.http_client().fetch(req).await
@@ -171,6 +173,8 @@ impl B2Core {
171173

172174
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
173175

176+
let req = req.extension(Operation::Write);
177+
174178
// Set body
175179
let req = req.body(Buffer::new()).map_err(new_request_build_error)?;
176180

@@ -264,6 +268,8 @@ impl B2Core {
264268
req = req.header(header::CONTENT_DISPOSITION, pos)
265269
}
266270

271+
let req = req.extension(Operation::Write);
272+
267273
// Set body
268274
let req = req.body(body).map_err(new_request_build_error)?;
269275

@@ -291,6 +297,8 @@ impl B2Core {
291297
mime.clone_into(&mut start_large_file_request.content_type)
292298
}
293299

300+
let req = req.extension(Operation::Write);
301+
294302
let body =
295303
serde_json::to_vec(&start_large_file_request).map_err(new_json_serialize_error)?;
296304
let body = bytes::Bytes::from(body);
@@ -314,6 +322,8 @@ impl B2Core {
314322

315323
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
316324

325+
let req = req.extension(Operation::Write);
326+
317327
// Set body
318328
let req = req.body(Buffer::new()).map_err(new_request_build_error)?;
319329

@@ -350,6 +360,8 @@ impl B2Core {
350360

351361
req = req.header(X_BZ_CONTENT_SHA1, "do_not_verify");
352362

363+
let req = req.extension(Operation::Write);
364+
353365
// Set body
354366
let req = req.body(body).map_err(new_request_build_error)?;
355367

@@ -369,6 +381,8 @@ impl B2Core {
369381

370382
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
371383

384+
let req = req.extension(Operation::Write);
385+
372386
let body = serde_json::to_vec(&FinishLargeFileRequest {
373387
file_id: file_id.to_owned(),
374388
part_sha1_array,
@@ -393,6 +407,8 @@ impl B2Core {
393407

394408
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
395409

410+
let req = req.extension(Operation::Write);
411+
396412
let body = serde_json::to_vec(&CancelLargeFileRequest {
397413
file_id: file_id.to_owned(),
398414
})
@@ -444,6 +460,8 @@ impl B2Core {
444460

445461
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
446462

463+
let req = req.extension(Operation::List);
464+
447465
// Set body
448466
let req = req.body(Buffer::new()).map_err(new_request_build_error)?;
449467

@@ -461,6 +479,8 @@ impl B2Core {
461479

462480
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
463481

482+
let req = req.extension(Operation::Copy);
483+
464484
let body = CopyFileRequest {
465485
source_file_id,
466486
file_name: to,
@@ -488,6 +508,8 @@ impl B2Core {
488508

489509
req = req.header(header::AUTHORIZATION, auth_info.authorization_token);
490510

511+
let req = req.extension(Operation::Delete);
512+
491513
let body = HideFileRequest {
492514
bucket_id: self.bucket_id.clone(),
493515
file_name: path.to_string(),

0 commit comments

Comments
 (0)