remove: needless clone
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// dead rust-lang/rustfmt/pull/5394 :(
|
||||
#![feature(
|
||||
decl_macro,
|
||||
duration_constructors,
|
||||
never_type,
|
||||
once_cell_try,
|
||||
seek_stream_len,
|
||||
seek_stream_len
|
||||
)]
|
||||
#![allow(clippy::future_not_send)] // will get to fix these later
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ pub enum NewCookieError {
|
||||
// MimeDBPath(#[from] magic::cookie::InvalidDatabasePathError),
|
||||
}
|
||||
|
||||
pub struct Mime {
|
||||
magic_dbs: magic::cookie::DatabasePaths,
|
||||
pub struct Mime<'a> {
|
||||
magic_dbs: &'a magic::cookie::DatabasePaths,
|
||||
}
|
||||
|
||||
impl Mime {
|
||||
impl<'a> Mime<'a> {
|
||||
thread_local! {
|
||||
static COOKIE_CELL: OnceCell<Cookie<cookie::Load>> = const { OnceCell::new() };
|
||||
}
|
||||
@@ -32,7 +32,7 @@ impl Mime {
|
||||
Self::COOKIE_CELL.with(|cookie| {
|
||||
let may_cookie = cookie.get_or_try_init::<_, NewCookieError>(move || {
|
||||
let cookie = magic::Cookie::open(magic::cookie::Flags::MIME)?;
|
||||
Ok(cookie.load(&self.magic_dbs)?)
|
||||
Ok(cookie.load(self.magic_dbs)?)
|
||||
});
|
||||
|
||||
match may_cookie {
|
||||
@@ -43,7 +43,7 @@ impl Mime {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn new(magic_dbs: magic::cookie::DatabasePaths) -> Self {
|
||||
pub const fn new(magic_dbs: &'a magic::cookie::DatabasePaths) -> Self {
|
||||
Self { magic_dbs }
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct AppCache<'a> {
|
||||
// FIXME: blocks
|
||||
user_cache: UsersCache,
|
||||
// FIXME: blocks
|
||||
magic_mime_cookie: Mime,
|
||||
magic_mime_cookie: Mime<'a>,
|
||||
|
||||
/// MUST only contain users from an accepted group, we do not want to cache arbitrary usernames
|
||||
/// and blow memory up.
|
||||
@@ -47,7 +47,7 @@ impl<'a> AppCache<'a> {
|
||||
/// If weighter's usize doesn't fit in its u32
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
magic_dbs: magic::cookie::DatabasePaths,
|
||||
magic_dbs: &'a magic::cookie::DatabasePaths,
|
||||
only_groups: &'a [crate::serdes::Group],
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -19,7 +19,7 @@ pub async fn start_app(args: crate::args::Args, config: crate::conf::Config) ->
|
||||
let config = Box::leak(Box::new(config));
|
||||
|
||||
let cache = caches::AppCache::new(
|
||||
config.unix.magic_paths.clone(),
|
||||
&config.unix.magic_paths,
|
||||
&config.unix.groups,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user