Fix warnings

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/5/head
trivernis 3 years ago
parent 745c6bf856
commit acdad7ac7e
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,7 @@
use crate::error::RepoResult;
use multihash::{Code, MultihashDigest}; use multihash::{Code, MultihashDigest};
use crate::error::RepoResult;
/// Creates a new content descriptor for the given file /// Creates a new content descriptor for the given file
pub fn create_content_descriptor(bytes: &[u8]) -> Vec<u8> { pub fn create_content_descriptor(bytes: &[u8]) -> Vec<u8> {
Code::Sha2_256.digest(bytes).to_bytes() Code::Sha2_256.digest(bytes).to_bytes()

@ -1,8 +1,10 @@
use crate::settings::Settings;
use sea_orm::DatabaseConnection;
use std::sync::Arc; use std::sync::Arc;
use sea_orm::DatabaseConnection;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use crate::settings::Settings;
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct Context { pub struct Context {
pub settings: Arc<Mutex<Settings>>, pub settings: Arc<Mutex<Settings>>,

@ -1,5 +1,6 @@
use sea_orm::DbErr;
use std::fmt::{Debug, Formatter}; use std::fmt::{Debug, Formatter};
use sea_orm::DbErr;
use thiserror::Error; use thiserror::Error;
pub type RepoResult<T> = Result<T, RepoError>; pub type RepoResult<T> = Result<T, RepoError>;

@ -1,5 +1,6 @@
use std::io::Result; use std::io::Result;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tokio::fs::{File, OpenOptions}; use tokio::fs::{File, OpenOptions};
/// A file that only exists while being owned. /// A file that only exists while being owned.

@ -1,11 +1,13 @@
use crate::content_descriptor::{create_content_descriptor, encode_content_descriptor};
use crate::error::RepoResult;
use crate::utils::get_folder_size;
use std::path::PathBuf; use std::path::PathBuf;
use tokio::fs; use tokio::fs;
use tokio::fs::{File, OpenOptions}; use tokio::fs::{File, OpenOptions};
use tokio::io::{AsyncRead, AsyncReadExt, BufReader}; use tokio::io::{AsyncRead, AsyncReadExt, BufReader};
use crate::content_descriptor::{create_content_descriptor, encode_content_descriptor};
use crate::error::RepoResult;
use crate::utils::get_folder_size;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct FileHashStore { pub struct FileHashStore {
path: PathBuf, path: PathBuf,

@ -1,12 +1,14 @@
use crate::error::RepoResult;
use crate::utils::get_folder_size;
use std::fmt::Debug; use std::fmt::Debug;
use std::io::Result; use std::io::Result;
use std::path::PathBuf; use std::path::PathBuf;
use tokio::fs; use tokio::fs;
use tokio::fs::OpenOptions; use tokio::fs::OpenOptions;
use tokio::io::{AsyncWriteExt, BufWriter}; use tokio::io::{AsyncWriteExt, BufWriter};
use crate::error::RepoResult;
use crate::utils::get_folder_size;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ThumbnailStore { pub struct ThumbnailStore {
path: PathBuf, path: PathBuf,

@ -1,19 +1,21 @@
mod logging; use std::fs;
mod paths; use std::path::PathBuf;
mod server;
pub mod v1;
use crate::error::RepoResult;
use crate::settings::v1::SettingsV1;
use config::{Config, FileFormat}; use config::{Config, FileFormat};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
pub use logging::*; pub use logging::*;
pub use paths::*; pub use paths::*;
pub use server::*; pub use server::*;
use crate::error::RepoResult;
use crate::settings::v1::SettingsV1;
mod logging;
mod paths;
mod server;
pub mod v1;
#[derive(Clone, Debug, Deserialize, Serialize, Default)] #[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct Settings { pub struct Settings {
pub server: ServerSettings, pub server: ServerSettings,

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathSettings { pub struct PathSettings {
pub(crate) database_directory: String, pub(crate) database_directory: String,

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use std::net::IpAddr; use std::net::IpAddr;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, Default)] #[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct ServerSettings { pub struct ServerSettings {
pub tcp: TcpServerSettings, pub tcp: TcpServerSettings,

@ -1,7 +1,9 @@
use crate::error::RepoResult;
use serde::{Deserialize, Serialize};
use std::net::IpAddr; use std::net::IpAddr;
use serde::{Deserialize, Serialize};
use crate::error::RepoResult;
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SettingsV1 { pub struct SettingsV1 {
pub listen_address: IpAddr, pub listen_address: IpAddr,

@ -1,10 +1,12 @@
use crate::settings::Settings;
use mediarepo_api::types::repo::SizeType;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use mediarepo_api::types::repo::SizeType;
use tokio_graceful_shutdown::SubsystemHandle; use tokio_graceful_shutdown::SubsystemHandle;
use typemap_rev::TypeMapKey; use typemap_rev::TypeMapKey;
use crate::settings::Settings;
pub struct SettingsKey; pub struct SettingsKey;
impl TypeMapKey for SettingsKey { impl TypeMapKey for SettingsKey {

@ -1,9 +1,11 @@
use crate::error::RepoResult;
use futures::future;
use std::path::PathBuf; use std::path::PathBuf;
use futures::future;
use tokio::fs::{self, OpenOptions}; use tokio::fs::{self, OpenOptions};
use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::io::{AsyncBufReadExt, BufReader};
use crate::error::RepoResult;
/// Parses a normalized tag into its two components of namespace and tag /// Parses a normalized tag into its two components of namespace and tag
pub fn parse_namespace_and_tag(norm_tag: String) -> (Option<String>, String) { pub fn parse_namespace_and_tag(norm_tag: String) -> (Option<String>, String) {
norm_tag norm_tag

@ -1,7 +1,9 @@
use mediarepo_core::error::RepoDatabaseResult; use std::time::Duration;
use sea_orm::{ConnectOptions, Database, DatabaseConnection}; use sea_orm::{ConnectOptions, Database, DatabaseConnection};
use sqlx::migrate::MigrateDatabase; use sqlx::migrate::MigrateDatabase;
use std::time::Duration;
use mediarepo_core::error::RepoDatabaseResult;
pub mod entities; pub mod entities;
pub mod queries; pub mod queries;

@ -1,11 +1,13 @@
use mediarepo_core::error::RepoResult;
use sea_orm::DbBackend;
use sea_orm::FromQueryResult;
use sea_orm::{DatabaseConnection, Statement};
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Display; use std::fmt::Display;
use std::iter::FromIterator; use std::iter::FromIterator;
use sea_orm::{DatabaseConnection, Statement};
use sea_orm::DbBackend;
use sea_orm::FromQueryResult;
use mediarepo_core::error::RepoResult;
#[derive(Debug, FromQueryResult)] #[derive(Debug, FromQueryResult)]
struct CIDNamespaceTag { struct CIDNamespaceTag {
cd_id: i64, cd_id: i64,

@ -1,12 +1,14 @@
use crate::dto::{AddFileDto, FileDto}; use std::io::Cursor;
use chrono::{Local, NaiveDateTime}; use chrono::{Local, NaiveDateTime};
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use sea_orm::ActiveValue::Set; use sea_orm::ActiveValue::Set;
use sea_orm::{ActiveModelTrait, ConnectionTrait, DatabaseTransaction}; use sea_orm::{ActiveModelTrait, ConnectionTrait, DatabaseTransaction};
use std::io::Cursor;
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use crate::dao::file::FileDao; use crate::dao::file::FileDao;
use crate::dto::{AddFileDto, FileDto};
impl FileDao { impl FileDao {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]

@ -1,11 +1,13 @@
use crate::dao::file::{map_file_and_cd, FileDao}; use sea_orm::ConnectionTrait;
use crate::dto::FileDto; use sea_orm::prelude::*;
use mediarepo_core::error::{RepoError, RepoResult};
use mediarepo_core::error::{RepoResult};
use mediarepo_database::entities::{ use mediarepo_database::entities::{
content_descriptor, content_descriptor_tag, file, file_metadata, content_descriptor, content_descriptor_tag, file, file_metadata,
}; };
use sea_orm::prelude::*;
use sea_orm::ConnectionTrait; use crate::dao::file::{FileDao};
use crate::dto::FileDto;
impl FileDao { impl FileDao {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]

@ -1,14 +1,16 @@
use crate::dao::file::{map_cd_and_file, FileDao};
use crate::dto::FileDto;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, QuerySelect};
use sea_orm::Condition;
use sea_orm::sea_query::{Alias, Expr, Query, SimpleExpr};
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor; use mediarepo_database::entities::content_descriptor;
use mediarepo_database::entities::content_descriptor_tag; use mediarepo_database::entities::content_descriptor_tag;
use mediarepo_database::entities::file; use mediarepo_database::entities::file;
use mediarepo_database::entities::file_metadata; use mediarepo_database::entities::file_metadata;
use sea_orm::sea_query::{Alias, Expr, Query, SimpleExpr};
use sea_orm::Condition; use crate::dao::file::{FileDao, map_cd_and_file};
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, QuerySelect}; use crate::dto::FileDto;
macro_rules! apply_ordering_comparator { macro_rules! apply_ordering_comparator {
($column:expr, $filter:expr) => { ($column:expr, $filter:expr) => {

@ -1,10 +1,12 @@
use crate::dao::{DaoContext, DaoProvider};
use crate::dto::{FileDto, FileMetadataDto, ThumbnailDto};
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use sea_orm::prelude::*; use sea_orm::prelude::*;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use crate::dao::{DaoContext, DaoProvider};
use crate::dto::{FileDto, FileMetadataDto, ThumbnailDto};
pub mod add; pub mod add;
pub mod delete; pub mod delete;
pub mod find; pub mod find;

@ -1,18 +1,20 @@
use crate::dto::{FileDto, FileMetadataDto, ThumbnailDto, UpdateFileDto, UpdateFileMetadataDto}; use std::fmt::Debug;
use std::io::Cursor;
use std::str::FromStr;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::{Set, Unchanged};
use sea_orm::{ConnectionTrait, NotSet};
use mediarepo_core::error::{RepoError, RepoResult}; use mediarepo_core::error::{RepoError, RepoResult};
use mediarepo_core::fs::thumbnail_store::Dimensions; use mediarepo_core::fs::thumbnail_store::Dimensions;
use mediarepo_core::thumbnailer; use mediarepo_core::thumbnailer;
use mediarepo_core::thumbnailer::{Thumbnail, ThumbnailSize}; use mediarepo_core::thumbnailer::{ThumbnailSize};
use mediarepo_database::entities::{content_descriptor, file, file_metadata}; use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use sea_orm::prelude::*;
use sea_orm::ActiveValue::{Set, Unchanged};
use sea_orm::{ConnectionTrait, NotSet};
use std::fmt::Debug;
use std::io::Cursor;
use std::str::FromStr;
use crate::dao::file::FileDao; use crate::dao::file::FileDao;
use crate::dao::opt_to_active_val; use crate::dao::opt_to_active_val;
use crate::dto::{FileDto, FileMetadataDto, ThumbnailDto, UpdateFileDto, UpdateFileMetadataDto};
impl FileDao { impl FileDao {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]

@ -1,12 +1,14 @@
use crate::dao::{DaoContext, DaoProvider}; use sea_orm::ActiveValue::Set;
use sea_orm::ConnectionTrait;
use sea_orm::prelude::*;
use mediarepo_core::content_descriptor::{ use mediarepo_core::content_descriptor::{
convert_v1_descriptor_to_v2, encode_content_descriptor, is_v1_content_descriptor, convert_v1_descriptor_to_v2, encode_content_descriptor, is_v1_content_descriptor,
}; };
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor; use mediarepo_database::entities::content_descriptor;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set; use crate::dao::{DaoContext, DaoProvider};
use sea_orm::ConnectionTrait;
pub struct JobDao { pub struct JobDao {
ctx: DaoContext, ctx: DaoContext,
@ -30,13 +32,13 @@ impl JobDao {
tracing::info!("Converting content descriptors to v2 format..."); tracing::info!("Converting content descriptors to v2 format...");
let mut converted_count = 0; let mut converted_count = 0;
for mut cd in cds { for cd in cds {
if is_v1_content_descriptor(&cd.descriptor) { if is_v1_content_descriptor(&cd.descriptor) {
let trx = self.ctx.db.begin().await?; let trx = self.ctx.db.begin().await?;
let src_cd = cd.descriptor; let src_cd = cd.descriptor;
let dst_cd = convert_v1_descriptor_to_v2(&src_cd)?; let dst_cd = convert_v1_descriptor_to_v2(&src_cd)?;
let active_model = content_descriptor::ActiveModel { let _active_model = content_descriptor::ActiveModel {
id: Set(cd.id), id: Set(cd.id),
descriptor: Set(dst_cd.clone()), descriptor: Set(dst_cd.clone()),
}; };

@ -1,14 +1,16 @@
pub mod file; use sea_orm::{ActiveValue, DatabaseConnection};
pub mod job;
pub mod repo; use mediarepo_core::fs::file_hash_store::FileHashStore;
pub mod tag; use mediarepo_core::fs::thumbnail_store::ThumbnailStore;
use crate::dao::file::FileDao; use crate::dao::file::FileDao;
use crate::dao::job::JobDao; use crate::dao::job::JobDao;
use crate::dao::tag::TagDao; use crate::dao::tag::TagDao;
use mediarepo_core::fs::file_hash_store::FileHashStore;
use mediarepo_core::fs::thumbnail_store::ThumbnailStore; pub mod file;
use sea_orm::{ActiveValue, DatabaseConnection}; pub mod job;
pub mod repo;
pub mod tag;
#[derive(Clone)] #[derive(Clone)]
pub struct DaoContext { pub struct DaoContext {

@ -1,29 +1,30 @@
use crate::dao::{DaoContext, DaoProvider};
use crate::file_metadata::FileMetadata;
use crate::namespace::Namespace;
use crate::tag::Tag;
use chrono::{Local, NaiveDateTime};
use mediarepo_core::content_descriptor::{
convert_v1_descriptor_to_v2, encode_content_descriptor, is_v1_content_descriptor,
};
use mediarepo_core::error::{RepoError, RepoResult};
use mediarepo_core::fs::file_hash_store::FileHashStore;
use mediarepo_core::fs::thumbnail_store::{Dimensions, ThumbnailStore};
use mediarepo_core::itertools::Itertools;
use mediarepo_core::thumbnailer::ThumbnailSize;
use mediarepo_core::utils::parse_namespace_and_tag;
use mediarepo_database::entities::content_descriptor;
use mediarepo_database::get_database;
use mediarepo_database::queries::analysis::{get_all_counts, Counts};
use sea_orm::DatabaseConnection;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fmt::Debug; use std::fmt::Debug;
use std::io::Cursor;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr;
use tokio::fs::OpenOptions;
use tokio::io::AsyncReadExt;
use sea_orm::DatabaseConnection;
use mediarepo_core::error::{RepoResult};
use mediarepo_core::fs::file_hash_store::FileHashStore;
use mediarepo_core::fs::thumbnail_store::{ThumbnailStore};
use mediarepo_core::itertools::Itertools;
use mediarepo_core::utils::parse_namespace_and_tag;
use mediarepo_database::get_database;
use mediarepo_database::queries::analysis::{Counts, get_all_counts};
use crate::dao::{DaoContext, DaoProvider};
use crate::file_metadata::FileMetadata;
use crate::namespace::Namespace;
use crate::tag::Tag;
#[derive(Clone)] #[derive(Clone)]
pub struct Repo { pub struct Repo {

@ -1,9 +1,11 @@
use crate::dao::tag::TagDao; use sea_orm::{ConnectionTrait, DatabaseTransaction};
use sea_orm::ActiveValue::Set;
use sea_orm::prelude::*;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor_tag; use mediarepo_database::entities::content_descriptor_tag;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set; use crate::dao::tag::TagDao;
use sea_orm::{ConnectionTrait, DatabaseTransaction};
impl TagDao { impl TagDao {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]

@ -1,12 +1,14 @@
pub mod mappings; use sea_orm::prelude::*;
use sea_orm::QuerySelect;
use sea_orm::{JoinType};
use crate::dao::{DaoContext, DaoProvider};
use crate::dto::TagDto;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, content_descriptor_tag, namespace, tag}; use mediarepo_database::entities::{content_descriptor, content_descriptor_tag, namespace, tag};
use sea_orm::prelude::*;
use sea_orm::QuerySelect; use crate::dao::{DaoContext, DaoProvider};
use sea_orm::{DatabaseConnection, JoinType}; use crate::dto::TagDto;
pub mod mappings;
pub struct TagDao { pub struct TagDao {
ctx: DaoContext, ctx: DaoContext,

@ -1,11 +1,13 @@
use crate::dto::FileMetadataDto;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use mediarepo_core::content_descriptor::encode_content_descriptor; use mediarepo_core::content_descriptor::encode_content_descriptor;
use mediarepo_core::mediarepo_api::types::files::FileStatus as ApiFileStatus; use mediarepo_core::mediarepo_api::types::files::FileStatus as ApiFileStatus;
use mediarepo_database::entities::content_descriptor; use mediarepo_database::entities::content_descriptor;
use mediarepo_database::entities::file; use mediarepo_database::entities::file;
use mediarepo_database::entities::file_metadata; use mediarepo_database::entities::file_metadata;
use crate::dto::FileMetadataDto;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct FileDto { pub struct FileDto {
model: file::Model, model: file::Model,

@ -1,4 +1,5 @@
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use mediarepo_database::entities::file_metadata; use mediarepo_database::entities::file_metadata;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

@ -1,11 +1,12 @@
pub use file::*;
pub use file_metadata::*;
pub use namespace::*;
pub use tag::*;
pub use thumbnail::*;
mod file; mod file;
mod file_metadata; mod file_metadata;
mod tag; mod tag;
mod namespace; mod namespace;
mod thumbnail; mod thumbnail;
pub use file::*;
pub use file_metadata::*;
pub use tag::*;
pub use namespace::*;
pub use thumbnail::*;

@ -1,5 +1,6 @@
pub use mediarepo_database::entities::tag;
pub use mediarepo_database::entities::namespace; pub use mediarepo_database::entities::namespace;
pub use mediarepo_database::entities::tag;
use crate::dto::NamespaceDto; use crate::dto::NamespaceDto;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -12,7 +13,7 @@ impl TagDto {
pub(crate) fn new(model: tag::Model, namespace_model: Option<namespace::Model>) -> Self { pub(crate) fn new(model: tag::Model, namespace_model: Option<namespace::Model>) -> Self {
Self { Self {
model, model,
namespace: namespace_model.map(NamespaceDto::new) namespace: namespace_model.map(NamespaceDto::new),
} }
} }
@ -27,4 +28,4 @@ impl TagDto {
pub fn namespace(&self) -> Option<&NamespaceDto> { pub fn namespace(&self) -> Option<&NamespaceDto> {
self.namespace.as_ref() self.namespace.as_ref()
} }
} }

@ -1,10 +1,12 @@
use mediarepo_core::error::RepoResult;
use mediarepo_core::fs::thumbnail_store::Dimensions;
use std::path::PathBuf; use std::path::PathBuf;
use tokio::fs; use tokio::fs;
use tokio::fs::{File, OpenOptions}; use tokio::fs::{File, OpenOptions};
use tokio::io::BufReader; use tokio::io::BufReader;
use mediarepo_core::error::RepoResult;
use mediarepo_core::fs::thumbnail_store::Dimensions;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ThumbnailDto { pub struct ThumbnailDto {
path: PathBuf, path: PathBuf,

@ -1,10 +1,12 @@
use mediarepo_core::error::RepoResult; use std::fmt::Debug;
use mediarepo_database::entities::namespace;
use sea_orm::prelude::*;
use sea_orm::{ use sea_orm::{
Condition, ConnectionTrait, DatabaseBackend, DatabaseConnection, InsertResult, Set, Statement, Condition, ConnectionTrait, DatabaseBackend, DatabaseConnection, InsertResult, Set, Statement,
}; };
use std::fmt::Debug; use sea_orm::prelude::*;
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::namespace;
#[derive(Clone)] #[derive(Clone)]
pub struct Namespace { pub struct Namespace {

@ -1,15 +1,16 @@
use std::fmt::Debug; use std::fmt::Debug;
use sea_orm::{Condition, DatabaseBackend, DatabaseConnection, JoinType, Set, Statement};
use sea_orm::{InsertResult, QuerySelect};
use sea_orm::prelude::*;
use sea_orm::query::ConnectionTrait;
use sea_orm::sea_query::Expr;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor; use mediarepo_database::entities::content_descriptor;
use mediarepo_database::entities::content_descriptor_tag; use mediarepo_database::entities::content_descriptor_tag;
use mediarepo_database::entities::namespace; use mediarepo_database::entities::namespace;
use mediarepo_database::entities::tag; use mediarepo_database::entities::tag;
use sea_orm::prelude::*;
use sea_orm::query::ConnectionTrait;
use sea_orm::sea_query::Expr;
use sea_orm::{Condition, DatabaseBackend, DatabaseConnection, JoinType, Set, Statement};
use sea_orm::{InsertResult, QuerySelect};
use crate::namespace::Namespace; use crate::namespace::Namespace;

@ -1,7 +1,9 @@
use crate::dao::repo::Repo;
use std::sync::Arc; use std::sync::Arc;
use typemap_rev::TypeMapKey; use typemap_rev::TypeMapKey;
use crate::dao::repo::Repo;
pub struct RepoKey; pub struct RepoKey;
impl TypeMapKey for RepoKey { impl TypeMapKey for RepoKey {

@ -1,3 +1,10 @@
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::net::TcpListener;
use tokio::task::JoinHandle;
use mediarepo_core::bromine::prelude::*; use mediarepo_core::bromine::prelude::*;
use mediarepo_core::error::{RepoError, RepoResult}; use mediarepo_core::error::{RepoError, RepoResult};
use mediarepo_core::mediarepo_api::types::misc::InfoResponse; use mediarepo_core::mediarepo_api::types::misc::InfoResponse;
@ -6,11 +13,6 @@ use mediarepo_core::tokio_graceful_shutdown::SubsystemHandle;
use mediarepo_core::type_keys::{RepoPathKey, SettingsKey, SizeMetadataKey, SubsystemKey}; use mediarepo_core::type_keys::{RepoPathKey, SettingsKey, SizeMetadataKey, SubsystemKey};
use mediarepo_logic::dao::repo::Repo; use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::type_keys::RepoKey; use mediarepo_logic::type_keys::RepoKey;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::net::TcpListener;
use tokio::task::JoinHandle;
mod from_model; mod from_model;
mod namespaces; mod namespaces;

@ -1,10 +1,5 @@
mod searching; use tokio::io::AsyncReadExt;
mod sorting;
use crate::from_model::FromModel;
use crate::namespaces::files::searching::find_files_for_filters;
use crate::namespaces::files::sorting::sort_files_by_properties;
use crate::utils::{cd_by_identifier, file_by_identifier, get_repo_from_context};
use mediarepo_core::bromine::prelude::*; use mediarepo_core::bromine::prelude::*;
use mediarepo_core::content_descriptor::{create_content_descriptor, encode_content_descriptor}; use mediarepo_core::content_descriptor::{create_content_descriptor, encode_content_descriptor};
use mediarepo_core::error::RepoError; use mediarepo_core::error::RepoError;
@ -21,7 +16,14 @@ use mediarepo_core::thumbnailer::ThumbnailSize;
use mediarepo_core::utils::parse_namespace_and_tag; use mediarepo_core::utils::parse_namespace_and_tag;
use mediarepo_logic::dao::DaoProvider; use mediarepo_logic::dao::DaoProvider;
use mediarepo_logic::dto::{AddFileDto, UpdateFileDto, UpdateFileMetadataDto}; use mediarepo_logic::dto::{AddFileDto, UpdateFileDto, UpdateFileMetadataDto};
use tokio::io::AsyncReadExt;
use crate::from_model::FromModel;
use crate::namespaces::files::searching::find_files_for_filters;
use crate::namespaces::files::sorting::sort_files_by_properties;
use crate::utils::{cd_by_identifier, file_by_identifier, get_repo_from_context};
mod searching;
mod sorting;
pub struct FilesNamespace; pub struct FilesNamespace;

@ -1,15 +1,16 @@
use std::collections::HashMap;
use mediarepo_core::content_descriptor::decode_content_descriptor; use mediarepo_core::content_descriptor::decode_content_descriptor;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_core::mediarepo_api::types::files::FileStatus as ApiFileStatus; use mediarepo_core::mediarepo_api::types::files::FileStatus as ApiFileStatus;
use mediarepo_core::mediarepo_api::types::filtering::{ use mediarepo_core::mediarepo_api::types::filtering::{
FilterExpression, FilterQuery, PropertyQuery, TagQuery, ValueComparator, FilterExpression, FilterQuery, PropertyQuery, TagQuery, ValueComparator,
}; };
use mediarepo_logic::dao::file::find::NegatableComparator::{Is, IsNot}; use mediarepo_logic::dao::DaoProvider;
use mediarepo_logic::dao::file::find::{FilterFileProperty, FilterProperty, OrderingComparator}; use mediarepo_logic::dao::file::find::{FilterFileProperty, FilterProperty, OrderingComparator};
use mediarepo_logic::dao::file::find::NegatableComparator::{Is, IsNot};
use mediarepo_logic::dao::repo::Repo; use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::dao::DaoProvider;
use mediarepo_logic::dto::{FileDto, FileStatus}; use mediarepo_logic::dto::{FileDto, FileStatus};
use std::collections::HashMap;
#[tracing::instrument(level = "debug", skip(repo))] #[tracing::instrument(level = "debug", skip(repo))]
pub async fn find_files_for_filters( pub async fn find_files_for_filters(

@ -1,18 +1,20 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::iter::FromIterator;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use compare::Compare; use compare::Compare;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_core::mediarepo_api::types::filtering::{SortDirection, SortKey}; use mediarepo_core::mediarepo_api::types::filtering::{SortDirection, SortKey};
use mediarepo_database::queries::tags::{ use mediarepo_database::queries::tags::{
get_cids_with_namespaced_tags, get_content_descriptors_with_tag_count, get_cids_with_namespaced_tags, get_content_descriptors_with_tag_count,
}; };
use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::dao::DaoProvider; use mediarepo_logic::dao::DaoProvider;
use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::dto::{FileDto, FileMetadataDto}; use mediarepo_logic::dto::{FileDto, FileMetadataDto};
use mediarepo_logic::file_metadata::FileMetadata;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::iter::FromIterator;
pub struct FileSortContext { pub struct FileSortContext {
name: Option<String>, name: Option<String>,

@ -1,4 +1,3 @@
use crate::utils::{calculate_size, get_repo_from_context};
use mediarepo_core::bromine::prelude::*; use mediarepo_core::bromine::prelude::*;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_core::mediarepo_api::types::jobs::{JobType, RunJobRequest}; use mediarepo_core::mediarepo_api::types::jobs::{JobType, RunJobRequest};
@ -6,6 +5,8 @@ use mediarepo_core::mediarepo_api::types::repo::SizeType;
use mediarepo_core::type_keys::SizeMetadataKey; use mediarepo_core::type_keys::SizeMetadataKey;
use mediarepo_logic::dao::DaoProvider; use mediarepo_logic::dao::DaoProvider;
use crate::utils::{calculate_size, get_repo_from_context};
pub struct JobsNamespace; pub struct JobsNamespace;
impl NamespaceProvider for JobsNamespace { impl NamespaceProvider for JobsNamespace {

@ -1,5 +1,5 @@
use crate::from_model::FromModel; use rayon::iter::{IntoParallelIterator, ParallelIterator};
use crate::utils::{file_by_identifier, get_repo_from_context};
use mediarepo_core::bromine::prelude::*; use mediarepo_core::bromine::prelude::*;
use mediarepo_core::content_descriptor::decode_content_descriptor; use mediarepo_core::content_descriptor::decode_content_descriptor;
use mediarepo_core::mediarepo_api::types::files::{GetFileTagsRequest, GetFilesTagsRequest}; use mediarepo_core::mediarepo_api::types::files::{GetFileTagsRequest, GetFilesTagsRequest};
@ -7,7 +7,9 @@ use mediarepo_core::mediarepo_api::types::tags::{
ChangeFileTagsRequest, NamespaceResponse, TagResponse, ChangeFileTagsRequest, NamespaceResponse, TagResponse,
}; };
use mediarepo_logic::dao::DaoProvider; use mediarepo_logic::dao::DaoProvider;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use crate::from_model::FromModel;
use crate::utils::{file_by_identifier, get_repo_from_context};
pub struct TagsNamespace; pub struct TagsNamespace;

@ -1,3 +1,7 @@
use std::sync::Arc;
use tokio::fs;
use mediarepo_core::bromine::ipc::context::Context; use mediarepo_core::bromine::ipc::context::Context;
use mediarepo_core::content_descriptor::decode_content_descriptor; use mediarepo_core::content_descriptor::decode_content_descriptor;
use mediarepo_core::error::{RepoError, RepoResult}; use mediarepo_core::error::{RepoError, RepoResult};
@ -5,12 +9,10 @@ use mediarepo_core::mediarepo_api::types::identifier::FileIdentifier;
use mediarepo_core::mediarepo_api::types::repo::SizeType; use mediarepo_core::mediarepo_api::types::repo::SizeType;
use mediarepo_core::type_keys::{RepoPathKey, SettingsKey}; use mediarepo_core::type_keys::{RepoPathKey, SettingsKey};
use mediarepo_core::utils::get_folder_size; use mediarepo_core::utils::get_folder_size;
use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::dao::DaoProvider; use mediarepo_logic::dao::DaoProvider;
use mediarepo_logic::dao::repo::Repo;
use mediarepo_logic::dto::FileDto; use mediarepo_logic::dto::FileDto;
use mediarepo_logic::type_keys::RepoKey; use mediarepo_logic::type_keys::RepoKey;
use std::sync::Arc;
use tokio::fs;
pub async fn get_repo_from_context(ctx: &Context) -> Arc<Repo> { pub async fn get_repo_from_context(ctx: &Context) -> Arc<Repo> {
let data = ctx.data.read().await; let data = ctx.data.read().await;

@ -1,21 +1,22 @@
use console_subscriber::ConsoleLayer;
use rolling_file::RollingConditionBasic;
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use mediarepo_core::settings::LoggingSettings; use console_subscriber::ConsoleLayer;
use rolling_file::RollingConditionBasic;
use tracing::Level; use tracing::Level;
use tracing_appender::non_blocking::{NonBlocking, WorkerGuard}; use tracing_appender::non_blocking::{NonBlocking, WorkerGuard};
use tracing_flame::FlameLayer; use tracing_flame::FlameLayer;
use tracing_log::LogTracer; use tracing_log::LogTracer;
use tracing_subscriber::filter::{self, Targets};
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{ use tracing_subscriber::{
fmt::{self}, fmt::{self},
Layer, Registry, Layer, Registry,
}; };
use tracing_subscriber::filter::{self, Targets};
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use mediarepo_core::settings::LoggingSettings;
#[allow(dyn_drop)] #[allow(dyn_drop)]
pub type DropGuard = Box<dyn Drop>; pub type DropGuard = Box<dyn Drop>;

@ -1,7 +1,10 @@
use std::env;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::Duration;
use structopt::StructOpt; use structopt::StructOpt;
use tokio::fs; use tokio::fs;
use tokio::io::AsyncWriteExt;
use tokio::runtime; use tokio::runtime;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
@ -11,9 +14,6 @@ use mediarepo_core::settings::{PathSettings, Settings};
use mediarepo_core::tokio_graceful_shutdown::{SubsystemHandle, Toplevel}; use mediarepo_core::tokio_graceful_shutdown::{SubsystemHandle, Toplevel};
use mediarepo_logic::dao::repo::Repo; use mediarepo_logic::dao::repo::Repo;
use mediarepo_socket::start_tcp_server; use mediarepo_socket::start_tcp_server;
use std::env;
use std::time::Duration;
use tokio::io::AsyncWriteExt;
use crate::utils::{create_paths_for_repo, get_repo, load_settings}; use crate::utils::{create_paths_for_repo, get_repo, load_settings};

@ -1,9 +1,11 @@
use std::path::PathBuf;
use tokio::fs;
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_core::settings::v1::SettingsV1;
use mediarepo_core::settings::{PathSettings, Settings}; use mediarepo_core::settings::{PathSettings, Settings};
use mediarepo_core::settings::v1::SettingsV1;
use mediarepo_logic::dao::repo::Repo; use mediarepo_logic::dao::repo::Repo;
use std::path::PathBuf;
use tokio::fs;
/// Loads the settings from a toml path /// Loads the settings from a toml path
pub fn load_settings(root_path: &PathBuf) -> RepoResult<Settings> { pub fn load_settings(root_path: &PathBuf) -> RepoResult<Settings> {

Loading…
Cancel
Save