chore: clean up imports

concurrent-repos
Jef Roosens 2024-05-27 22:56:37 +02:00
parent 32e27978ec
commit 48f2d00c94
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
12 changed files with 66 additions and 63 deletions

View File

@ -32,5 +32,6 @@ features = [
"sqlx-postgres", "sqlx-postgres",
"runtime-tokio-rustls", "runtime-tokio-rustls",
"macros", "macros",
"with-chrono" "with-chrono",
"debug-print"
] ]

View File

@ -1,13 +1,13 @@
mod pagination; mod pagination;
use axum::extract::{Path, Query, State}; use crate::db;
use axum::routing::get;
use axum::Json;
use axum::Router;
use pagination::PaginatedResponse; use pagination::PaginatedResponse;
use crate::db; use axum::{
extract::{Path, Query, State},
routing::get,
Json, Router,
};
pub fn router() -> Router<crate::Global> { pub fn router() -> Router<crate::Global> {
Router::new() Router::new()

View File

@ -1,13 +1,9 @@
use crate::repo::MetaRepoMgr; use crate::{repo::MetaRepoMgr, Config, Global};
use crate::{Config, Global};
use axum::extract::FromRef; use axum::{extract::FromRef, Router};
use axum::Router;
use clap::Parser; use clap::Parser;
use sea_orm_migration::MigratorTrait; use sea_orm_migration::MigratorTrait;
use std::io; use std::{io, path::PathBuf, sync::Arc};
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tower_http::trace::TraceLayer; use tower_http::trace::TraceLayer;
use tracing::debug; use tracing::debug;
@ -40,7 +36,7 @@ pub struct Cli {
#[arg( #[arg(
long, long,
value_name = "LOG_LEVEL", value_name = "LOG_LEVEL",
default_value = "tower_http=debug,rieterd=debug", default_value = "tower_http=debug,rieterd=debug,sea_orm=debug",
env = "RIETER_LOG" env = "RIETER_LOG"
)] )]
pub log: String, pub log: String,
@ -67,7 +63,7 @@ impl Cli {
url.clone() url.clone()
} else { } else {
format!( format!(
"sqlite://{}", "sqlite://{}?mode=rwc",
self.data_dir.join("rieter.sqlite").to_string_lossy() self.data_dir.join("rieter.sqlite").to_string_lossy()
) )
}; };
@ -80,6 +76,8 @@ impl Cli {
let db = sea_orm::Database::connect(options).await?; let db = sea_orm::Database::connect(options).await?;
crate::db::Migrator::up(&db, None).await?; crate::db::Migrator::up(&db, None).await?;
debug!("Successfully applied migrations");
let config = Config { let config = Config {
data_dir: self.data_dir.clone(), data_dir: self.data_dir.clone(),
}; };

View File

@ -2,13 +2,12 @@ pub mod entities;
mod migrator; mod migrator;
pub mod query; pub mod query;
use sea_orm::{DeriveActiveEnum, EnumIter};
use serde::{Deserialize, Serialize};
pub use entities::{prelude::*, *}; pub use entities::{prelude::*, *};
pub use migrator::Migrator; pub use migrator::Migrator;
use sea_orm::{DeriveActiveEnum, EnumIter};
use serde::{Deserialize, Serialize};
type Result<T> = std::result::Result<T, sea_orm::DbErr>; type Result<T> = std::result::Result<T, sea_orm::DbErr>;
#[derive(EnumIter, DeriveActiveEnum, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] #[derive(EnumIter, DeriveActiveEnum, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]

View File

@ -1,8 +1,8 @@
use crate::db::*;
use sea_orm::{sea_query::IntoCondition, *}; use sea_orm::{sea_query::IntoCondition, *};
use serde::Deserialize; use serde::Deserialize;
use crate::db::*;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct Filter { pub struct Filter {
repo: Option<i32>, repo: Option<i32>,

View File

@ -1,7 +1,7 @@
use sea_orm::{sea_query::IntoCondition, *};
use crate::db::*; use crate::db::*;
use sea_orm::{sea_query::IntoCondition, *};
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct Filter { pub struct Filter {
name: Option<String>, name: Option<String>,

View File

@ -1,9 +1,9 @@
use std::error::Error; use std::{error::Error, fmt, io};
use std::fmt;
use std::io;
use axum::http::StatusCode; use axum::{
use axum::response::{IntoResponse, Response}; http::StatusCode,
response::{IntoResponse, Response},
};
pub type Result<T> = std::result::Result<T, ServerError>; pub type Result<T> = std::result::Result<T, ServerError>;

View File

@ -4,11 +4,11 @@ pub mod db;
mod error; mod error;
mod repo; mod repo;
use clap::Parser;
pub use error::{Result, ServerError}; pub use error::{Result, ServerError};
use repo::MetaRepoMgr; use repo::MetaRepoMgr;
use std::path::PathBuf;
use std::sync::Arc; use clap::Parser;
use std::{path::PathBuf, sync::Arc};
use tokio::sync::RwLock; use tokio::sync::RwLock;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,9 +1,13 @@
use std::io; use std::{
use std::path::{Path, PathBuf}; io,
use std::sync::{Arc, Mutex}; path::{Path, PathBuf},
sync::{Arc, Mutex},
};
use libarchive::write::{Builder, FileWriter, WriteEntry}; use libarchive::{
use libarchive::{Entry, WriteFilter, WriteFormat}; write::{Builder, FileWriter, WriteEntry},
Entry, WriteFilter, WriteFormat,
};
/// Struct to abstract away the intrinsics of writing entries to an archive file /// Struct to abstract away the intrinsics of writing entries to an archive file
pub struct RepoArchiveWriter { pub struct RepoArchiveWriter {

View File

@ -1,15 +1,12 @@
use super::{archive, package};
use crate::{db, error::Result};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use sea_orm::{ColumnTrait, DbConn, ModelTrait, QueryFilter, QuerySelect};
use uuid::Uuid;
use futures::StreamExt; use futures::StreamExt;
use sea_orm::{ColumnTrait, DbConn, ModelTrait, QueryFilter, QuerySelect};
use tokio::io::AsyncRead; use tokio::io::AsyncRead;
use uuid::Uuid;
use super::archive;
use super::package;
use crate::db;
use crate::error::Result;
pub const ANY_ARCH: &'static str = "any"; pub const ANY_ARCH: &'static str = "any";

View File

@ -4,19 +4,19 @@ mod manager_new;
pub mod package; pub mod package;
pub use manager_new::MetaRepoMgr; pub use manager_new::MetaRepoMgr;
use tokio_util::io::StreamReader;
use axum::body::Body; use axum::{
use axum::extract::{Path, State}; body::Body,
use axum::http::Request; extract::{Path, State},
use axum::http::StatusCode; http::{Request, StatusCode},
use axum::response::IntoResponse; response::IntoResponse,
use axum::routing::{delete, post}; routing::{delete, post},
use axum::Router; Router,
};
use futures::TryStreamExt; use futures::TryStreamExt;
use tokio_util::io::StreamReader;
use tower::util::ServiceExt; use tower::util::ServiceExt;
use tower_http::services::ServeFile; use tower_http::{services::ServeFile, validate_request::ValidateRequestHeaderLayer};
use tower_http::validate_request::ValidateRequestHeaderLayer;
pub fn router(api_key: &str) -> Router<crate::Global> { pub fn router(api_key: &str) -> Router<crate::Global> {
Router::new() Router::new()

View File

@ -1,16 +1,20 @@
use crate::db::{self, entities::package, PackageRelatedEnum};
use std::{
fmt, fs,
io::{self, BufRead, BufReader, BufWriter, Read, Write},
path::{Path, PathBuf},
};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use futures::StreamExt; use futures::StreamExt;
use libarchive::read::{Archive, Builder}; use libarchive::{
use libarchive::{Entry, ReadFilter}; read::{Archive, Builder},
Entry, ReadFilter,
};
use sea_orm::{ActiveValue::Set, ColumnTrait, DbConn, ModelTrait, QueryFilter, QuerySelect}; use sea_orm::{ActiveValue::Set, ColumnTrait, DbConn, ModelTrait, QueryFilter, QuerySelect};
use std::fmt;
use std::fs;
use std::io::{self, BufRead, BufReader, BufWriter, Read, Write};
use std::path::{Path, PathBuf};
use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio::io::{AsyncWrite, AsyncWriteExt};
use crate::db::{self, entities::package, PackageRelatedEnum};
const IGNORED_FILES: [&str; 5] = [".BUILDINFO", ".INSTALL", ".MTREE", ".PKGINFO", ".CHANGELOG"]; const IGNORED_FILES: [&str; 5] = [".BUILDINFO", ".INSTALL", ".MTREE", ".PKGINFO", ".CHANGELOG"];
#[derive(Debug, Clone)] #[derive(Debug, Clone)]