Skip to content

Commit

Permalink
fix: compilation and format
Browse files Browse the repository at this point in the history
  • Loading branch information
llenotre committed Nov 10, 2024
1 parent fc70b06 commit d279dc8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
13 changes: 6 additions & 7 deletions client/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use crate::confirm;
#[cfg(feature = "network")]
use common::repository::remote::Remote;
use common::{
anyhow,
anyhow::{bail, Result},
package::Package,
repository,
repository::Repository,
Environment,
};
use std::{collections::HashMap, path::PathBuf};
use utils::util::ByteSize;

// TODO Clean
/// Installs the given list of packages.
Expand Down Expand Up @@ -130,12 +128,12 @@ pub async fn install(
}
}

println!("Total download size: {}", ByteSize(total_size));
println!("Total download size: {}", utils::util::ByteSize(total_size));
}
#[cfg(not(feature = "network"))]
{
for pkg in total_packages.keys() {
println!("\t- {} ({}) - cached", pkg.get_name(), pkg.get_version());
println!("\t- {} ({}) - cached", pkg.name, pkg.version);
}
}

Expand Down Expand Up @@ -167,8 +165,7 @@ pub async fn install(
while task.next().await? > 0 {
// TODO update progress bar
}

Ok::<(), anyhow::Error>(())
Ok::<(), common::anyhow::Error>(())
},
));
}
Expand All @@ -178,7 +175,9 @@ pub async fn install(
for (name, version, f) in futures {
match f.await {
Ok(()) => continue,
Err(e) => eprintln!("Failed to download `{name}` version `{version}`: {e}"),
Err(error) => {
eprintln!("Failed to download `{name}` version `{version}`: {error}")
}
}
}
if failed {
Expand Down
4 changes: 2 additions & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ reqwest = { version = "0.12.9", features = ["blocking", "json", "stream"], optio
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
tar = "0.4.43"
tokio = { version = "1.41.1", features = ["rt", "rt-multi-thread"] }
tokio-util = "0.7.12"
tokio = { version = "1.41.1", features = ["fs", "rt", "rt-multi-thread"] }
tokio-util = { version = "0.7.12", features = ["io"] }
xz2 = "0.1.7"

[features]
Expand Down
3 changes: 1 addition & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ mod route;

use axum::{routing::get, Router};
use common::{repository::Repository, tokio};
use std::{io, sync::Arc};
use std::path::PathBuf;
use serde::Deserialize;
use std::{io, path::PathBuf, sync::Arc};

/// The server's configuration.
#[derive(Deserialize)]
Expand Down
17 changes: 8 additions & 9 deletions server/src/route/package.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
//! Package endpoints.
use std::sync::Arc;
use crate::Context;
use axum::{
body::Body,
extract::{Path, State},
http::StatusCode,
http::{header::CONTENT_TYPE, StatusCode},
response::{IntoResponse, Response},
Json,
};
use axum::body::Body;
use axum::http::header::CONTENT_TYPE;
use common::{package, version::Version};
use common::{package, tokio::fs::File, tokio_util::io::ReaderStream, version::Version};
use std::sync::Arc;
use tracing::error;
use common::tokio::fs::File;
use common::tokio_util::io::ReaderStream;

/// Endpoint to list packages.
pub async fn list(State(ctx): State<Arc<Context>>) -> Response {
Expand Down Expand Up @@ -63,8 +60,10 @@ pub async fn archive(
// Check package exists
let res = ctx.repo.get_package(&name, &version);
match res {
Ok(Some(_)) => {},
Ok(None) => return (StatusCode::NOT_FOUND, "package or version not found").into_response(),
Ok(Some(_)) => {}
Ok(None) => {
return (StatusCode::NOT_FOUND, "package or version not found").into_response()
}
Err(error) => {
error!(%error, name, %version, "could read package");
return (StatusCode::INTERNAL_SERVER_ERROR, "internal server error").into_response();
Expand Down

0 comments on commit d279dc8

Please sign in to comment.