Skip to content

Commit

Permalink
mirror-intel: use get instead of head (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzh authored Dec 12, 2020
1 parent 652999b commit 1d49cd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/crates_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 5 additions & 3 deletions src/mirror_intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ impl SnapshotStorage<String> for MirrorIntel {
impl TargetStorage<String> 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);
Expand Down

0 comments on commit 1d49cd7

Please sign in to comment.