chore: fix all clippy warnings
This commit is contained in:
parent
9cec2e0dc2
commit
fde56af414
13 changed files with 119 additions and 158 deletions
|
|
@ -88,7 +88,7 @@ pub async fn connect(conn: &DbConfig) -> crate::Result<DbConn> {
|
|||
} => {
|
||||
let mut url = format!("postgres://{}:{}@{}:{}/{}", user, password, host, port, db);
|
||||
|
||||
if schema != "" {
|
||||
if !schema.is_empty() {
|
||||
url = format!("{url}?currentSchema={schema}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ use sea_orm_migration::MigratorTrait;
|
|||
use tokio::runtime;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
pub const ANY_ARCH: &'static str = "any";
|
||||
pub const PKG_FILENAME_REGEX: &'static str = "^([a-z0-9@._+-]+)-((?:[0-9]+:)?[a-zA-Z0-9@._+]+-[0-9]+)-([a-zA-z0-9_]+).pkg.tar.([a-zA-Z0-9]+)$";
|
||||
pub const ANY_ARCH: &str = "any";
|
||||
pub const PKG_FILENAME_REGEX: &str = "^([a-z0-9@._+-]+)-((?:[0-9]+:)?[a-zA-Z0-9@._+]+-[0-9]+)-([a-zA-z0-9_]+).pkg.tar.([a-zA-Z0-9]+)$";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Global {
|
||||
|
|
|
|||
|
|
@ -216,8 +216,8 @@ impl RepoArchivesWriter {
|
|||
self.ar_db.close()?;
|
||||
self.ar_files.close()?;
|
||||
|
||||
let _ = std::fs::remove_file(&self.tmp_paths[0])?;
|
||||
let _ = std::fs::remove_file(&self.tmp_paths[1])?;
|
||||
let _ = std::fs::remove_file(&self.tmp_paths[0]);
|
||||
let _ = std::fs::remove_file(&self.tmp_paths[1]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,14 @@ pub enum Command {
|
|||
Clean,
|
||||
}
|
||||
|
||||
type RepoState = (AtomicU32, Arc<Mutex<()>>);
|
||||
|
||||
pub struct SharedState {
|
||||
pub repos_dir: PathBuf,
|
||||
pub conn: DbConn,
|
||||
pub rx: Mutex<UnboundedReceiver<Command>>,
|
||||
pub tx: UnboundedSender<Command>,
|
||||
pub repos: RwLock<HashMap<i32, (AtomicU32, Arc<Mutex<()>>)>>,
|
||||
pub repos: RwLock<HashMap<i32, RepoState>>,
|
||||
}
|
||||
|
||||
impl SharedState {
|
||||
|
|
|
|||
|
|
@ -48,18 +48,18 @@ pub struct PkgInfo {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ParsePkgInfoError {
|
||||
InvalidSize,
|
||||
InvalidBuildDate,
|
||||
InvalidPgpSigSize,
|
||||
pub enum InvalidPkgInfoError {
|
||||
Size,
|
||||
BuildDate,
|
||||
PgpSigSize,
|
||||
}
|
||||
|
||||
impl fmt::Display for ParsePkgInfoError {
|
||||
impl fmt::Display for InvalidPkgInfoError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let s = match self {
|
||||
Self::InvalidSize => "invalid size",
|
||||
Self::InvalidBuildDate => "invalid build date",
|
||||
Self::InvalidPgpSigSize => "invalid pgp sig size",
|
||||
Self::Size => "invalid size",
|
||||
Self::BuildDate => "invalid build date",
|
||||
Self::PgpSigSize => "invalid pgp sig size",
|
||||
};
|
||||
|
||||
write!(f, "{}", s)
|
||||
|
|
@ -67,7 +67,7 @@ impl fmt::Display for ParsePkgInfoError {
|
|||
}
|
||||
|
||||
impl PkgInfo {
|
||||
pub fn extend<S: AsRef<str>>(&mut self, line: S) -> Result<(), ParsePkgInfoError> {
|
||||
pub fn extend<S: AsRef<str>>(&mut self, line: S) -> Result<(), InvalidPkgInfoError> {
|
||||
let line = line.as_ref();
|
||||
|
||||
if !line.starts_with('#') {
|
||||
|
|
@ -77,26 +77,21 @@ impl PkgInfo {
|
|||
"pkgbase" => self.base = value.to_string(),
|
||||
"pkgver" => self.version = value.to_string(),
|
||||
"pkgdesc" => self.description = Some(value.to_string()),
|
||||
"size" => {
|
||||
self.size = value.parse().map_err(|_| ParsePkgInfoError::InvalidSize)?
|
||||
}
|
||||
"size" => self.size = value.parse().map_err(|_| InvalidPkgInfoError::Size)?,
|
||||
"url" => self.url = Some(value.to_string()),
|
||||
"arch" => self.arch = value.to_string(),
|
||||
"builddate" => {
|
||||
let seconds: i64 = value
|
||||
.parse()
|
||||
.map_err(|_| ParsePkgInfoError::InvalidBuildDate)?;
|
||||
self.build_date = NaiveDateTime::from_timestamp_millis(seconds * 1000)
|
||||
.ok_or(ParsePkgInfoError::InvalidBuildDate)?
|
||||
let seconds: i64 =
|
||||
value.parse().map_err(|_| InvalidPkgInfoError::BuildDate)?;
|
||||
self.build_date = chrono::DateTime::from_timestamp_millis(seconds * 1000)
|
||||
.ok_or(InvalidPkgInfoError::BuildDate)?
|
||||
.naive_utc();
|
||||
}
|
||||
"packager" => self.packager = Some(value.to_string()),
|
||||
"pgpsig" => self.pgpsig = Some(value.to_string()),
|
||||
"pgpsigsize" => {
|
||||
self.pgpsigsize = Some(
|
||||
value
|
||||
.parse()
|
||||
.map_err(|_| ParsePkgInfoError::InvalidPgpSigSize)?,
|
||||
)
|
||||
self.pgpsigsize =
|
||||
Some(value.parse().map_err(|_| InvalidPkgInfoError::PgpSigSize)?)
|
||||
}
|
||||
"group" => self.groups.push(value.to_string()),
|
||||
"license" => self.licenses.push(value.to_string()),
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@ async fn delete_arch_repo(
|
|||
}
|
||||
|
||||
async fn delete_package(
|
||||
State(global): State<crate::Global>,
|
||||
Path((distro, repo, arch, pkg_name)): Path<(String, String, String, String)>,
|
||||
State(_global): State<crate::Global>,
|
||||
Path((_distro, _repo, _arch, _pkg_name)): Path<(String, String, String, String)>,
|
||||
) -> crate::Result<StatusCode> {
|
||||
Ok(StatusCode::NOT_FOUND)
|
||||
//if let Some(mgr) = global.mgr.get_mgr(&distro).await {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue