Fix clippy lints and fix README
This commit is contained in:
parent
9212e5a7f3
commit
c13a5d5ddf
|
@ -6,7 +6,7 @@ To run this, you need to:
|
||||||
- Create a `registry.toml` file in the current directory with the following contents:
|
- Create a `registry.toml` file in the current directory with the following contents:
|
||||||
```toml
|
```toml
|
||||||
working_dir = "/path/to/some/directory"
|
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"
|
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
|
```sql
|
||||||
INSERT INTO users (login, credential) VALUES ('username', 'account token')
|
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`.
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub async fn update_crate_from_db(
|
||||||
registry: dep.registry,
|
registry: dep.registry,
|
||||||
},
|
},
|
||||||
package: dep.package,
|
package: dep.package,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
versions2.push(CrateVersion {
|
versions2.push(CrateVersion {
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,3 +1,10 @@
|
||||||
|
#![warn(clippy::pedantic)]
|
||||||
|
#![allow(
|
||||||
|
clippy::module_name_repetitions,
|
||||||
|
clippy::similar_names,
|
||||||
|
clippy::let_underscore_drop
|
||||||
|
)]
|
||||||
|
|
||||||
mod db;
|
mod db;
|
||||||
mod download;
|
mod download;
|
||||||
mod index;
|
mod index;
|
||||||
|
@ -34,6 +41,7 @@ pub struct Errors {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
fn new(v: impl ToString) -> Self {
|
||||||
Self {
|
Self {
|
||||||
errors: vec![SingleError {
|
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> {
|
pub async fn auth(crate_name: &str, auth_user: &DbUser, state: &State) -> Result<(), Response> {
|
||||||
let (is_authenticated,): (bool,) =
|
let (is_authenticated,): (bool,) =
|
||||||
query_as("SELECT $1 = ANY (crates.owners) FROM crates WHERE name = $2")
|
query_as("SELECT $1 = ANY (crates.owners) FROM crates WHERE name = $2")
|
||||||
|
|
|
@ -108,6 +108,8 @@ struct Warnings {
|
||||||
other: Vec<String>,
|
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(
|
pub async fn new_crate(
|
||||||
mut request: NewCrateRequest,
|
mut request: NewCrateRequest,
|
||||||
Auth(auth_user): Auth,
|
Auth(auth_user): Auth,
|
||||||
|
|
|
@ -12,8 +12,6 @@ use sqlx::{query, query_as};
|
||||||
|
|
||||||
use crate::{auth, db::PgU32, db_error, Auth, Errors, RespResult, State, Success};
|
use crate::{auth, db::PgU32, db_error, Auth, Errors, RespResult, State, Success};
|
||||||
|
|
||||||
// TODO: custom `Json` errors
|
|
||||||
|
|
||||||
pub struct Json<T>(T);
|
pub struct Json<T>(T);
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
|
@ -83,7 +83,7 @@ pub async fn search(
|
||||||
name: craet.1,
|
name: craet.1,
|
||||||
max_version: vers.parse().unwrap(),
|
max_version: vers.parse().unwrap(),
|
||||||
description: desc.unwrap_or_else(|| "".to_owned()),
|
description: desc.unwrap_or_else(|| "".to_owned()),
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue