Fix clippy lints and fix README

This commit is contained in:
Yash Karandikar 2022-08-03 12:13:03 -05:00 committed by missing
parent 9212e5a7f3
commit c13a5d5ddf
6 changed files with 18 additions and 6 deletions

View file

@ -6,7 +6,7 @@ To run this, you need to:
- Create a `registry.toml` file in the current directory with the following contents:
```toml
working_dir = "/path/to/some/directory"
postgres_uri = "postgres://1.2.3.4/db_name"
postgres_uri = "postgres://user:pass@db_host/db_name"
listen_uri = "0.0.0.0:1234"
```
@ -48,4 +48,4 @@ Creating accounts is currently not managed by this code. You will have to run th
```sql
INSERT INTO users (login, credential) VALUES ('username', 'account token')
```
You can then give out the token for someone else to use with `cargo login`.
You can then give out the token for someone else to use with `cargo login`.

View file

@ -120,7 +120,7 @@ pub async fn update_crate_from_db(
registry: dep.registry,
},
package: dep.package,
})
});
}
versions2.push(CrateVersion {

View file

@ -1,3 +1,10 @@
#![warn(clippy::pedantic)]
#![allow(
clippy::module_name_repetitions,
clippy::similar_names,
clippy::let_underscore_drop
)]
mod db;
mod download;
mod index;
@ -34,6 +41,7 @@ pub struct Errors {
}
impl Errors {
#[allow(clippy::needless_pass_by_value)] // I'd fix this but frankly I'm too lazy
fn new(v: impl ToString) -> Self {
Self {
errors: vec![SingleError {
@ -211,6 +219,10 @@ impl FromRequest<Body> for Auth {
}
}
/// Checks if the user has permissions to modify the crate.
///
/// # Errors
/// Returns a FORBIDDEN status code if the user does not have the required permissions.
pub async fn auth(crate_name: &str, auth_user: &DbUser, state: &State) -> Result<(), Response> {
let (is_authenticated,): (bool,) =
query_as("SELECT $1 = ANY (crates.owners) FROM crates WHERE name = $2")

View file

@ -108,6 +108,8 @@ struct Warnings {
other: Vec<String>,
}
// FIXME: i'm not gonna touch this code for fear of breaking it, you can handle it later ig
#[allow(clippy::too_many_lines)]
pub async fn new_crate(
mut request: NewCrateRequest,
Auth(auth_user): Auth,

View file

@ -12,8 +12,6 @@ use sqlx::{query, query_as};
use crate::{auth, db::PgU32, db_error, Auth, Errors, RespResult, State, Success};
// TODO: custom `Json` errors
pub struct Json<T>(T);
#[async_trait]

View file

@ -83,7 +83,7 @@ pub async fn search(
name: craet.1,
max_version: vers.parse().unwrap(),
description: desc.unwrap_or_else(|| "".to_owned()),
})
});
}
}