Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ciehanski committed Nov 10, 2023
1 parent ee8f652 commit 50edffe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Job {

// Create job's provider client
let client = self.provider.get_client().await?;

for run in self.runs.iter() {
for kfc in run.1.delta.iter() {
if kfc.file.path == fpath {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/gdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl KipProvider for KipGdrive {
mime_type: Some("application/vnd.google-apps.folder".to_string()),
..Default::default()
};
let (_, result) = hub
let (_, result) = hub
.files()
.create(req)
.add_scope(Scope::File)
Expand Down
24 changes: 6 additions & 18 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,47 +87,35 @@ impl KipProviders {
}
}

pub async fn download<'b>(
&self,
client: &KipClient,
file_name: &str,
) -> Result<Vec<u8>> {
pub async fn download<'b>(&self, client: &KipClient, file_name: &str) -> Result<Vec<u8>> {
match self {
Self::S3(s3) => match client {
KipClient::S3(client) => {
s3.download(Some(client), file_name).await
}
KipClient::S3(client) => s3.download(Some(client), file_name).await,
_ => {
bail!("s3 client not provided")
}
},
Self::Usb(usb) => usb.download(None, file_name).await,
Self::Gdrive(gdrive) => match client {
KipClient::Gdrive(client) => {
gdrive.download(Some(client), file_name).await
}
KipClient::Gdrive(client) => gdrive.download(Some(client), file_name).await,
_ => {
bail!("gdrive client not provided")
}
}
},
}
}

pub async fn delete(&self, client: &KipClient, remote_path: &str) -> Result<()> {
match self {
Self::S3(s3) => match client {
KipClient::S3(client) => {
s3.delete(Some(client), remote_path).await
}
KipClient::S3(client) => s3.delete(Some(client), remote_path).await,
_ => {
bail!("s3 client not provided")
}
},
Self::Usb(usb) => usb.delete(None, remote_path).await,
Self::Gdrive(gdrive) => match client {
KipClient::Gdrive(client) => {
gdrive.delete(Some(client), remote_path).await
}
KipClient::Gdrive(client) => gdrive.delete(Some(client), remote_path).await,
_ => {
bail!("gdrive client not provided")
}
Expand Down
6 changes: 3 additions & 3 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::compress::{
};
use crate::crypto::{decrypt, encrypt_bytes, encrypt_in_place};
use crate::job::{Job, KipFile, KipStatus};
use crate::providers::{KipClient, KipUploadOpts};
use crate::providers::KipProviders;
use crate::providers::{KipClient, KipUploadOpts};
use anyhow::{bail, Result};
use chrono::prelude::*;
use colored::*;
Expand Down Expand Up @@ -493,7 +493,6 @@ impl Run {
// For each object in the bucket, download it
let mut counter: u64 = 0;
for kfc in self.delta.iter() {

let local_path = kfc.file.path.display().to_string();

if kfc.is_single_chunk() {
Expand Down Expand Up @@ -529,7 +528,8 @@ impl Run {
// Download all chunks
let mut chunks_stream = tokio_stream::iter(kfc.chunks.values());
while let Some(chunk) = chunks_stream.next().await {
let chunk_bytes = match job.provider.download(&client, &chunk.remote_path).await {
let chunk_bytes = match job.provider.download(&client, &chunk.remote_path).await
{
Ok(cb) => cb,
Err(e) => {
error!("error downloading chunk {}: {e}", &chunk.remote_path);
Expand Down

0 comments on commit 50edffe

Please sign in to comment.