Implement missing client api

Signed-off-by: Trivernis <trivernis@protonmail.com>
pull/4/head
Trivernis 3 years ago
parent fb139c9091
commit bddce4d60a

@ -250,9 +250,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
[[package]]
name = "bromine"
version = "0.16.1"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "913d14c7bfcf3b8ea8a6fc9fc2217dc734a9557c54ebe2dd4a3cc8e769ffffc4"
checksum = "6569b994f61cbc4c1d597d809a322cc994a99b878e7235276d088d8da9736a72"
dependencies = [
"async-trait",
"bincode",
@ -1136,8 +1136,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.16.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=9599020726eb9db47b9be7a6c41c2942a477ba09#9599020726eb9db47b9be7a6c41c2942a477ba09"
version = "0.17.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=72e4d902aff409feab8db10546b81a452ec6f75f#72e4d902aff409feab8db10546b81a452ec6f75f"
dependencies = [
"bromine",
"chrono",

@ -1,3 +1,7 @@
[workspace]
members = ["mediarepo-core", "mediarepo-database", "mediarepo-model", "mediarepo-socket", "."]
default-members = ["mediarepo-core", "mediarepo-database", "mediarepo-model", "mediarepo-socket", "."]
[package]
name = "mediarepo-daemon"
version = "0.10.0"
@ -12,17 +16,17 @@ name = "mediarepo-daemon"
path = "src/main.rs"
[dependencies]
tracing = "0.1.29"
toml = "0.5.8"
structopt ="0.3.25"
glob = "0.3.0"
tracing-flame = "0.2.0"
tracing-appender = "0.2.0"
tracing-log = "0.1.2"
rolling-file = "0.1.0"
num-integer = "0.1.44"
console-subscriber = "0.1.0"
log = "0.4.14"
tracing = "^0.1.29"
toml = "^0.5.8"
structopt ="^0.3.25"
glob = "^0.3.0"
tracing-flame = "^0.2.0"
tracing-appender = "^0.2.0"
tracing-log = "^0.1.2"
rolling-file = "^0.1.0"
num-integer = "^0.1.44"
console-subscriber = "^0.1.0"
log = "^0.4.14"
[dependencies.mediarepo-core]
path = "./mediarepo-core"

File diff suppressed because it is too large Load Diff

@ -2,41 +2,42 @@
name = "mediarepo-core"
version = "0.1.0"
edition = "2018"
workspace = ".."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
thiserror = "1.0.30"
multihash = "0.15.0"
multibase = "0.9.1"
base64 = "0.13.0"
toml = "0.5.8"
serde = "1.0.132"
typemap_rev = "0.1.5"
futures = "0.3.19"
itertools = "0.10.3"
glob = "0.3.0"
thiserror = "^1.0.30"
multihash = "^0.15.0"
multibase = "^0.9.1"
base64 = "^0.13.0"
toml = "^0.5.8"
serde = "^1.0.132"
typemap_rev = "^0.1.5"
futures = "^0.3.19"
itertools = "^0.10.3"
glob = "^0.3.0"
[dependencies.thumbnailer]
version = "0.2.4"
version = "^0.2.4"
default-features = false
[dependencies.sea-orm]
version = "0.5.0-rc.1"
version = "^0.5.0-rc.1"
default-features = false
[dependencies.sqlx]
version = "0.5.9"
version = "^0.5.9"
default-features = false
features = ["migrate"]
[dependencies.tokio]
version = "1.15.0"
version = "^1.15.0"
features = ["fs", "io-util", "io-std"]
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "9599020726eb9db47b9be7a6c41c2942a477ba09"
rev = "72e4d902aff409feab8db10546b81a452ec6f75f"
features = ["bromine"]
[features]

File diff suppressed because it is too large Load Diff

@ -2,21 +2,22 @@
name = "mediarepo-database"
version = "0.2.0"
edition = "2018"
workspace = ".."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.19"
tracing = "0.1.29"
chrono = "^0.4.19"
tracing = "^0.1.29"
[dependencies.mediarepo-core]
path = "../mediarepo-core"
[dependencies.sqlx]
version = "0.5.9"
version = "^0.5.9"
features = ["migrate"]
[dependencies.sea-orm]
version = "0.5.0-rc.1"
version = "^0.5.0-rc.1"
features = ["sqlx-sqlite", "runtime-tokio-native-tls", "macros", "debug-print"]
default-features = false

File diff suppressed because it is too large Load Diff

@ -2,17 +2,18 @@
name = "mediarepo-model"
version = "0.1.0"
edition = "2018"
workspace = ".."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.19"
typemap_rev = "0.1.5"
serde = "1.0.130"
mime_guess = "2.0.3"
mime = "0.3.16"
tracing = "0.1.29"
async-trait = "0.1.51"
chrono = "^0.4.19"
typemap_rev = "^0.1.5"
serde = "^1.0.130"
mime_guess = "^2.0.3"
mime = "^0.3.16"
tracing = "^0.1.29"
async-trait = "^0.1.51"
[dependencies.mediarepo-core]
@ -22,12 +23,12 @@ path = "../mediarepo-core"
path = "../mediarepo-database"
[dependencies.sea-orm]
version = "0.5.0-rc.1"
version = "^0.5.0-rc.1"
features = ["runtime-tokio-native-tls", "macros"]
default-features = false
[dependencies.tokio]
version = "1.15.0"
version = "^1.15.0"
features = ["fs", "io-std", "io-util"]

@ -19,6 +19,19 @@ impl Namespace {
Self { db, model }
}
/// Retrieves a list of all namespaces
#[tracing::instrument(level = "debug", skip(db))]
pub async fn all(db: DatabaseConnection) -> RepoResult<Vec<Self>> {
let namespaces = namespace::Entity::find()
.all(&db)
.await?
.into_iter()
.map(|model| Self::new(db.clone(), model))
.collect();
Ok(namespaces)
}
/// Retrieves the namespace by id
#[tracing::instrument(level = "debug", skip(db))]
pub async fn by_id(db: DatabaseConnection, id: i64) -> RepoResult<Option<Self>> {

@ -273,6 +273,12 @@ impl Repo {
Tag::all(self.db.clone()).await
}
/// Returns all namespaces stored in the database
#[tracing::instrument(level = "debug", skip(self))]
pub async fn namespaces(&self) -> RepoResult<Vec<Namespace>> {
Namespace::all(self.db.clone()).await
}
/// Finds all tags by name
#[tracing::instrument(level = "debug", skip(self))]
pub async fn tags_by_names(&self, tags: Vec<(Option<String>, String)>) -> RepoResult<Vec<Tag>> {

File diff suppressed because it is too large Load Diff

@ -2,14 +2,15 @@
name = "mediarepo-socket"
version = "0.1.0"
edition = "2018"
workspace = ".."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1.0.130"
tracing = "0.1.29"
compare = "0.1.0"
port_check = "0.1.5"
serde = "^1.0.130"
tracing = "^0.1.29"
compare = "^0.1.0"
port_check = "^0.1.5"
[dependencies.mediarepo-core]
path = "../mediarepo-core"
@ -21,11 +22,11 @@ path = "../mediarepo-database"
path = "../mediarepo-model"
[dependencies.tokio]
version = "1.12.0"
version = "^1.15.0"
features = ["net"]
[dependencies.chrono]
version = "0.4.19"
version = "^0.4.19"
features = ["serde"]
[dependencies.tracing-futures]

@ -1,8 +1,9 @@
use mediarepo_core::mediarepo_api::types::files::{
FileMetadataResponse, ThumbnailMetadataResponse,
};
use mediarepo_core::mediarepo_api::types::tags::TagResponse;
use mediarepo_core::mediarepo_api::types::tags::{NamespaceResponse, TagResponse};
use mediarepo_model::file::File;
use mediarepo_model::namespace::Namespace;
use mediarepo_model::tag::Tag;
use mediarepo_model::thumbnail::Thumbnail;
@ -46,3 +47,12 @@ impl FromModel<Thumbnail> for ThumbnailMetadataResponse {
}
}
}
impl FromModel<Namespace> for NamespaceResponse {
fn from_model(model: Namespace) -> Self {
Self {
id: model.id(),
name: model.name().to_owned(),
}
}
}

@ -41,6 +41,7 @@ impl NamespaceProvider for FilesNamespace {
events!(handler,
"all_files" => Self::all_files,
"get_file" => Self::get_file,
"get_files" => Self::get_files,
"find_files" => Self::find_files,
"add_file" => Self::add_file,
"read_file" => Self::read_file,
@ -81,6 +82,25 @@ impl FilesNamespace {
Ok(())
}
/// Returns a list of files by identifier
#[tracing::instrument(skip_all)]
async fn get_files(ctx: &Context, event: Event) -> IPCResult<()> {
let ids = event.payload::<Vec<FileIdentifier>>()?;
let repo = get_repo_from_context(ctx).await;
let mut responses = Vec::new();
for id in ids {
responses.push(
file_by_identifier(id, &repo)
.await
.map(FileMetadataResponse::from_model)?,
);
}
ctx.emit_to(Self::name(), "get_files", responses).await?;
Ok(())
}
/// Searches for files by tags
#[tracing::instrument(skip_all)]
async fn find_files(ctx: &Context, event: Event) -> IPCResult<()> {

@ -2,7 +2,9 @@ use crate::from_model::FromModel;
use crate::utils::{file_by_identifier, get_repo_from_context};
use mediarepo_core::bromine::prelude::*;
use mediarepo_core::mediarepo_api::types::files::{GetFileTagsRequest, GetFilesTagsRequest};
use mediarepo_core::mediarepo_api::types::tags::{ChangeFileTagsRequest, TagResponse};
use mediarepo_core::mediarepo_api::types::tags::{
ChangeFileTagsRequest, NamespaceResponse, TagResponse,
};
pub struct TagsNamespace;
@ -14,6 +16,7 @@ impl NamespaceProvider for TagsNamespace {
fn register(handler: &mut EventHandler) {
events!(handler,
"all_tags" => Self::all_tags,
"all_namespaces" => Self::all_namespaces,
"tags_for_file" => Self::tags_for_file,
"tags_for_files" => Self::tags_for_files,
"create_tags" => Self::create_tags,
@ -38,6 +41,22 @@ impl TagsNamespace {
Ok(())
}
/// Returns a list of all namespaces from the database
#[tracing::instrument(skip_all)]
async fn all_namespaces(ctx: &Context, _event: Event) -> IPCResult<()> {
let repo = get_repo_from_context(ctx).await;
let namespaces: Vec<NamespaceResponse> = repo
.namespaces()
.await?
.into_iter()
.map(NamespaceResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "all_namespaces", namespaces)
.await?;
Ok(())
}
/// Returns all tags for a single file
#[tracing::instrument(skip_all)]
async fn tags_for_file(ctx: &Context, event: Event) -> IPCResult<()> {

@ -66,7 +66,8 @@ pub fn init_tracing(repo_path: &PathBuf) -> Vec<DropGuard> {
let bromine_layer = fmt::layer()
.with_writer(bromine_writer)
.json()
.pretty()
.with_ansi(false)
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
.with_filter(filter::Targets::new().with_target("bromine", Level::DEBUG));
@ -75,7 +76,8 @@ pub fn init_tracing(repo_path: &PathBuf) -> Vec<DropGuard> {
let app_log_layer = fmt::layer()
.with_writer(app_log_writer)
.json()
.pretty()
.with_ansi(false)
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
.with_filter(
filter::Targets::new()

Loading…
Cancel
Save