From 1d49cd77a39c6278205c97a2e97dd8ec3aab443e Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Sat, 12 Dec 2020 20:25:14 +0800 Subject: [PATCH] mirror-intel: use get instead of head (#31) --- src/crates_io.rs | 2 +- src/mirror_intel.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/crates_io.rs b/src/crates_io.rs index 6711009..d3aebb8 100644 --- a/src/crates_io.rs +++ b/src/crates_io.rs @@ -4,7 +4,7 @@ use crate::traits::{SnapshotStorage, SourceStorage}; use async_trait::async_trait; use serde::Deserialize; -use slog::{debug, info}; +use slog::info; use std::io::Read; #[derive(Deserialize, Debug)] diff --git a/src/mirror_intel.rs b/src/mirror_intel.rs index f69fac8..18f0c79 100644 --- a/src/mirror_intel.rs +++ b/src/mirror_intel.rs @@ -53,15 +53,17 @@ impl SnapshotStorage for MirrorIntel { impl TargetStorage for MirrorIntel { async fn put_object(&self, item: String, mission: &Mission) -> Result<()> { let target_url = format!("{}/{}", self.config.base, item); - let response = self.client.head(&target_url).send().await?; + let response = self.client.get(&target_url).send().await?; + let headers = response.headers().clone(); + drop(response); - if let Some(location) = response.headers().get("Location") { + if let Some(location) = headers.get("Location") { if !location.to_str().unwrap().contains("jcloud") { tokio::time::delay_for(std::time::Duration::from_secs(1)).await; } } - if let Some(queue_length) = response.headers().get("X-Intel-Queue-Length") { + if let Some(queue_length) = headers.get("X-Intel-Queue-Length") { let queue_length: u64 = queue_length.to_str().unwrap().parse().unwrap(); if queue_length > 16384 { warn!(mission.logger, "queue full, length={}", queue_length);