Update bromine

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/14/head
trivernis 3 years ago
parent a14a342e40
commit d7e0f42fe2
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,6 @@
[package]
name = "mediarepo-api"
version = "0.28.1"
version = "0.29.0"
edition = "2018"
license = "gpl-3"
@ -15,12 +15,12 @@ serde_json = { version = "1.0.78", optional = true }
directories = { version = "4.0.1", optional = true }
mime_guess = { version = "2.0.3", optional = true }
serde_piecewise_default = "0.2.0"
futures = { version = "0.3.19", optional = true }
futures = { version = "0.3.21", optional = true }
url = { version = "2.2.2", optional = true }
pathsearch = { version = "0.2.0", optional = true }
[dependencies.bromine]
version = "0.17.1"
version = "0.18.1"
optional = true
features = ["serialize_bincode"]

@ -153,8 +153,11 @@ impl FileApi {
/// Permanently deletes a file from the disk and database
#[tracing::instrument(level = "debug", skip(self))]
pub async fn delete_file(&self, file_id: FileIdentifier) -> ApiResult<()> {
self.emit_and_get("delete_file", file_id, Some(Duration::from_secs(10)))
.await
self.emit("delete_file", file_id)
.await_reply()
.await?;
Ok(())
}
/// Returns a list of all thumbnails of the file
@ -198,7 +201,7 @@ impl FileApi {
/// Deletes all thumbnails of a file to regenerate them when requested
#[tracing::instrument(level = "debug", skip(self))]
pub async fn delete_thumbnails(&self, file_id: FileIdentifier) -> ApiResult<()> {
self.emit("delete_thumbnails", file_id).await?;
self.emit("delete_thumbnails", file_id).await_reply().await?;
Ok(())
}

@ -27,14 +27,17 @@ impl JobApi {
/// Runs a job of the given type and returns when it has finished
#[tracing::instrument(level = "debug", skip(self))]
pub async fn run_job(&self, job_type: JobType) -> ApiResult<()> {
self.emit_and_get(
self.emit(
"run_job",
RunJobRequest {
job_type,
sync: true,
},
Some(Duration::from_secs(3600)),
)
.await
.await_reply()
.with_timeout(Duration::from_secs(3600))
.await?;
Ok(())
}
}

@ -13,8 +13,8 @@ use crate::client_api::repo::RepoApi;
use crate::client_api::tag::TagApi;
use crate::types::misc::{check_apis_compatible, get_api_version, InfoResponse};
use async_trait::async_trait;
use bromine::ipc::stream_emitter::EmitMetadata;
use bromine::prelude::*;
use bromine::prelude::emit_metadata::EmitMetadata;
use tokio::time::Duration;
use crate::client_api::preset::PresetApi;
@ -84,12 +84,14 @@ impl ApiClient {
pub async fn connect<L: AsyncStreamProtocolListener>(
address: L::AddressType,
) -> ApiResult<Self> {
tracing::debug!("Connecting to {:?}", address);
let ctx = IPCBuilder::<L>::new()
.address(address)
.timeout(Duration::from_secs(10))
.build_pooled_client(8)
.await?;
let client = Self::new(ctx);
tracing::debug!("Retrieving info on daemon version...");
let info = client.info().await?;
let server_api_version = info.api_version();
@ -113,6 +115,8 @@ impl ApiClient {
pub async fn info(&self) -> ApiResult<InfoResponse> {
let ctx = self.ctx.acquire();
let res = ctx.emit("info", ()).await_reply().await?;
tracing::trace!("Got info event {:?}", res);
Ok(res.payload::<InfoResponse>()?)
}

@ -1,8 +1,8 @@
use std::time::Duration;
use bromine::prelude::*;
use crate::client_api::error::ApiResult;
use crate::types::filtering::{SortingPreset, SortKey};
use super::IPCApi;
use crate::client_api::error::ApiResult;
use crate::types::filtering::{SortKey, SortingPreset};
use bromine::prelude::*;
use std::time::Duration;
#[derive(Clone)]
pub struct PresetApi {
@ -27,28 +27,22 @@ impl PresetApi {
/// Returns all sorting presets of the repository
#[tracing::instrument(level = "debug", skip(self))]
pub async fn all_sorting_presets(&self) -> ApiResult<Vec<SortingPreset>> {
self.emit_and_get(
"all_sorting_presets",
(),
Some(Duration::from_secs(1))
)
self.emit_and_get("all_sorting_presets", (), Some(Duration::from_secs(1)))
.await
}
/// Adds a new sorting preset with the given keys
#[tracing::instrument(level = "debug", skip(self))]
pub async fn add_sorting_preset(&self, keys: Vec<SortKey>) -> ApiResult<SortingPreset> {
self.emit_and_get(
"add_sorting_preset",
keys,
Some(Duration::from_secs(1))
)
self.emit_and_get("add_sorting_preset", keys, Some(Duration::from_secs(1)))
.await
}
/// Deletes a given sorting preset by id
#[tracing::instrument(level = "debug", skip(self))]
pub async fn delete_sorting_preset(&self, id: i32) -> ApiResult<()> {
self.emit_and_get("delete_sorting_preset", id, Some(Duration::from_secs(1))).await
self.emit("delete_sorting_preset", id).await_reply().await?;
Ok(())
}
}

@ -269,15 +269,16 @@ dependencies = [
[[package]]
name = "bromine"
version = "0.17.1"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6774171be092328d9631f246d3122f196a50ddaad224214ca274acec2a1db65d"
checksum = "5dd7887995490657bf3ec578f39e747ef7b5355a8dc6c99b3d5be59ca70dc4d5"
dependencies = [
"async-trait",
"bincode",
"byteorder",
"futures 0.3.19",
"futures-core",
"lazy_static",
"num_enum",
"serde 1.0.136",
"thiserror",
"tokio",
@ -428,7 +429,7 @@ checksum = "829835c211a0247cd11e65e13cec8696b879374879c35ce162ce8098b23c90d4"
dependencies = [
"console-api",
"crossbeam-channel",
"futures 0.3.19",
"futures 0.3.21",
"hdrhistogram",
"humantime",
"serde 1.0.136",
@ -840,9 +841,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
[[package]]
name = "futures"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4"
checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
dependencies = [
"futures-channel",
"futures-core",
@ -855,9 +856,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b"
checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
dependencies = [
"futures-core",
"futures-sink",
@ -865,15 +866,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7"
checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]]
name = "futures-executor"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a"
checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6"
dependencies = [
"futures-core",
"futures-task",
@ -893,15 +894,15 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2"
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]]
name = "futures-macro"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c"
checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
"proc-macro2 1.0.36",
"quote 1.0.15",
@ -910,21 +911,21 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508"
checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
[[package]]
name = "futures-task"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72"
checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
[[package]]
name = "futures-util"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164"
checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
dependencies = [
"futures-channel",
"futures-core",
@ -1360,7 +1361,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.28.1"
version = "0.29.0"
dependencies = [
"bromine",
"chrono",
@ -1377,7 +1378,7 @@ dependencies = [
"base64",
"config",
"data-encoding",
"futures 0.3.19",
"futures 0.3.21",
"glob",
"itertools",
"mediarepo-api",
@ -1708,6 +1709,27 @@ dependencies = [
"libc",
]
[[package]]
name = "num_enum"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.36",
"quote 1.0.15",
"syn 1.0.86",
]
[[package]]
name = "num_threads"
version = "0.1.3"
@ -2196,14 +2218,14 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sea-orm"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5452736ac11d11f9dcf1980897d3a6302d78ee2bfcb928b0f9c03569f2e6b12c"
checksum = "dd24380b48dacd3ed1c3d467c7b17ffa5818555a2c04066f4a0a9e17d830abc9"
dependencies = [
"async-stream",
"async-trait",
"chrono",
"futures 0.3.19",
"futures 0.3.21",
"futures-util",
"once_cell",
"ouroboros",
@ -2221,9 +2243,9 @@ dependencies = [
[[package]]
name = "sea-orm-macros"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8b7b6d423b591bf447685e9ea7cecd65e0c282e18dc5ddc7438425cd296faa8"
checksum = "c199fa8630b1e195d7aef24ce8944af8f4ced67c4eccffd8926453b59f2565a1"
dependencies = [
"bae",
"heck",
@ -2234,9 +2256,9 @@ dependencies = [
[[package]]
name = "sea-query"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83e4a0dd79545b61c6ca453a28d0a88829487869a8559a35a3192f1b6aacad8"
checksum = "9088ff96158860a75d98a85a654fdd9d97b10515773af6d87339bfc48258c800"
dependencies = [
"chrono",
"rust_decimal",
@ -2812,7 +2834,7 @@ checksum = "d08ebea7dc6b22273290d8ece2ca448f979f836e38ba629b650595c64204b4f2"
dependencies = [
"anyhow",
"async-recursion",
"futures 0.3.19",
"futures 0.3.21",
"log",
"tokio",
"tokio-util",

@ -14,7 +14,7 @@ base64 = "0.13.0"
toml = "0.5.8"
serde = "1.0.136"
typemap_rev = "0.1.5"
futures = "0.3.19"
futures = "0.3.21"
itertools = "0.10.3"
glob = "0.3.0"
tracing = "0.1.30"
@ -26,7 +26,7 @@ version = "0.3.0"
default-features = false
[dependencies.sea-orm]
version = "0.5.0"
version = "0.6.0"
default-features = false
[dependencies.sqlx]

@ -18,6 +18,6 @@ version = "0.5.10"
features = ["migrate"]
[dependencies.sea-orm]
version = "0.5.0"
version = "0.6.0"
features = ["sqlx-sqlite", "runtime-tokio-native-tls", "macros", "debug-print"]
default-features = false

@ -22,7 +22,7 @@ path = "../mediarepo-core"
path = "../mediarepo-database"
[dependencies.sea-orm]
version = "0.5.0"
version = "0.6.0"
features = ["runtime-tokio-native-tls", "macros"]
default-features = false

@ -2,7 +2,7 @@ use std::io::Cursor;
use chrono::{Local, NaiveDateTime};
use sea_orm::ActiveValue::Set;
use sea_orm::{ActiveModelTrait, ConnectionTrait, DatabaseTransaction};
use sea_orm::{ActiveModelTrait, DatabaseTransaction, TransactionTrait};
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{content_descriptor, file, file_metadata};

@ -1,12 +1,12 @@
use sea_orm::ConnectionTrait;
use sea_orm::prelude::*;
use sea_orm::TransactionTrait;
use mediarepo_core::error::{RepoResult};
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{
content_descriptor, content_descriptor_tag, file, file_metadata,
};
use crate::dao::file::{FileDao};
use crate::dao::file::FileDao;
use crate::dto::FileDto;
impl FileDao {

@ -4,7 +4,7 @@ use std::str::FromStr;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::{Set, Unchanged};
use sea_orm::{ConnectionTrait, NotSet};
use sea_orm::{NotSet, TransactionTrait};
use mediarepo_core::error::{RepoError, RepoResult};
use mediarepo_core::fs::thumbnail_store::Dimensions;

@ -6,7 +6,7 @@ use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set;
use sea_orm::ConnectionTrait;
use sea_orm::TransactionTrait;
impl JobDao {
#[tracing::instrument(level = "debug", skip(self))]

@ -5,8 +5,8 @@ use mediarepo_database::entities::{sort_key, sorting_preset, sorting_preset_key}
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set;
use sea_orm::{
Condition, ConnectionTrait, DatabaseTransaction, DbBackend, FromQueryResult, JoinType,
QuerySelect, Statement,
Condition, DatabaseTransaction, DbBackend, FromQueryResult, JoinType, QuerySelect, Statement,
TransactionTrait,
};
#[allow(unused_imports)]

@ -4,7 +4,7 @@ use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{namespace, tag};
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set;
use sea_orm::{Condition, ConnectionTrait, DatabaseTransaction};
use sea_orm::{Condition, DatabaseTransaction, TransactionTrait};
use std::collections::HashMap;
use std::iter::FromIterator;

@ -1,6 +1,6 @@
use sea_orm::{ConnectionTrait, DatabaseTransaction};
use sea_orm::ActiveValue::Set;
use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set;
use sea_orm::{DatabaseTransaction, TransactionTrait};
use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor_tag;

@ -96,18 +96,17 @@ fn get_builder<L: AsyncStreamProtocolListener>(address: L::AddressType) -> IPCBu
}
#[tracing::instrument(skip_all)]
async fn info(ctx: &Context, _: Event) -> IPCResult<()> {
async fn info(ctx: &Context, _: Event) -> IPCResult<Response> {
let response = InfoResponse::new(
env!("CARGO_PKG_NAME").to_string(),
env!("CARGO_PKG_VERSION").to_string(),
);
ctx.emit("info", response).await?;
Ok(())
ctx.response(response)
}
#[tracing::instrument(skip_all)]
async fn shutdown(ctx: &Context, _: Event) -> IPCResult<()> {
async fn shutdown(ctx: &Context, _: Event) -> IPCResult<Response> {
ctx.clone().stop().await?;
{
let data = ctx.data.read().await;
@ -115,7 +114,6 @@ async fn shutdown(ctx: &Context, _: Event) -> IPCResult<()> {
subsystem.request_shutdown();
subsystem.on_shutdown_requested().await;
}
ctx.emit("shutdown", ()).await?;
Ok(())
Ok(Response::empty())
}

@ -54,7 +54,7 @@ impl NamespaceProvider for FilesNamespace {
impl FilesNamespace {
/// Returns a list of all files
#[tracing::instrument(skip_all)]
async fn all_files(ctx: &Context, _event: Event) -> IPCResult<()> {
async fn all_files(ctx: &Context, _event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let files = repo.file().all().await?;
@ -63,26 +63,23 @@ impl FilesNamespace {
.map(FileBasicDataResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "all_files", responses).await?;
Ok(())
ctx.response(responses)
}
/// Returns a file by id
#[tracing::instrument(skip_all)]
async fn get_file(ctx: &Context, event: Event) -> IPCResult<()> {
async fn get_file(ctx: &Context, event: Event) -> IPCResult<Response> {
let id = event.payload::<FileIdentifier>()?;
let repo = get_repo_from_context(ctx).await;
let file = file_by_identifier(id, &repo).await?;
let response = FileBasicDataResponse::from_model(file);
ctx.emit_to(Self::name(), "get_file", response).await?;
Ok(())
ctx.response(response)
}
/// Returns metadata for a given file
#[tracing::instrument(skip_all)]
async fn get_file_metadata(ctx: &Context, event: Event) -> IPCResult<()> {
async fn get_file_metadata(ctx: &Context, event: Event) -> IPCResult<Response> {
let id = event.payload::<FileIdentifier>()?;
let repo = get_repo_from_context(ctx).await;
let file = file_by_identifier(id, &repo).await?;
@ -97,19 +94,12 @@ impl FilesNamespace {
.ok_or_else(|| RepoError::from("file metadata not found"))?
};
ctx.emit_to(
Self::name(),
"get_file_metadata",
FileMetadataResponse::from_model(metadata),
)
.await?;
Ok(())
ctx.response(FileMetadataResponse::from_model(metadata))
}
/// Returns a list of files by identifier
#[tracing::instrument(skip_all)]
async fn get_files(ctx: &Context, event: Event) -> IPCResult<()> {
async fn get_files(ctx: &Context, event: Event) -> IPCResult<Response> {
let ids = event.payload::<Vec<FileIdentifier>>()?;
let repo = get_repo_from_context(ctx).await;
let mut responses = Vec::new();
@ -121,14 +111,13 @@ impl FilesNamespace {
.map(FileBasicDataResponse::from_model)?,
);
}
ctx.emit_to(Self::name(), "get_files", responses).await?;
Ok(())
ctx.response(responses)
}
/// Searches for files by tags
#[tracing::instrument(skip_all)]
async fn find_files(ctx: &Context, event: Event) -> IPCResult<()> {
async fn find_files(ctx: &Context, event: Event) -> IPCResult<Response> {
let req = event.payload::<FindFilesRequest>()?;
let repo = get_repo_from_context(ctx).await;
@ -139,13 +128,13 @@ impl FilesNamespace {
.into_iter()
.map(FileBasicDataResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "find_files", responses).await?;
Ok(())
ctx.response(responses)
}
/// Adds a file to the repository
#[tracing::instrument(skip_all)]
async fn add_file(ctx: &Context, event: Event) -> IPCResult<()> {
async fn add_file(ctx: &Context, event: Event) -> IPCResult<Response> {
let (request, bytes) = event
.payload::<TandemPayload<AddFileRequestHeader, BytePayload>>()?
.into_inner();
@ -184,18 +173,11 @@ impl FilesNamespace {
.upsert_mappings(vec![file.cd_id()], tag_ids)
.await?;
ctx.emit_to(
Self::name(),
"add_file",
FileBasicDataResponse::from_model(file),
)
.await?;
Ok(())
ctx.response(FileBasicDataResponse::from_model(file))
}
#[tracing::instrument(skip_all)]
async fn update_status(ctx: &Context, event: Event) -> IPCResult<()> {
async fn update_status(ctx: &Context, event: Event) -> IPCResult<Response> {
let request = event.payload::<UpdateFileStatusRequest>()?;
let repo = get_repo_from_context(ctx).await;
let mut file = file_by_identifier(request.file_id, &repo).await?;
@ -207,46 +189,35 @@ impl FilesNamespace {
..Default::default()
})
.await?;
ctx.emit_to(
Self::name(),
"update_file_status",
FileBasicDataResponse::from_model(file),
)
.await?;
Ok(())
ctx.response(FileBasicDataResponse::from_model(file))
}
/// Reads the binary contents of a file
#[tracing::instrument(skip_all)]
async fn read_file(ctx: &Context, event: Event) -> IPCResult<()> {
async fn read_file(ctx: &Context, event: Event) -> IPCResult<Response> {
let request = event.payload::<ReadFileRequest>()?;
let repo = get_repo_from_context(ctx).await;
let file = file_by_identifier(request.id, &repo).await?;
let bytes = repo.file().get_bytes(file.cd()).await?;
ctx.emit_to(Self::name(), "read_file", BytePayload::new(bytes))
.await?;
Ok(())
ctx.response(BytePayload::new(bytes))
}
/// Deletes a file
#[tracing::instrument(skip_all)]
async fn delete_file(ctx: &Context, event: Event) -> IPCResult<()> {
async fn delete_file(ctx: &Context, event: Event) -> IPCResult<Response> {
let id = event.payload::<FileIdentifier>()?;
let repo = get_repo_from_context(ctx).await;
let file = file_by_identifier(id, &repo).await?;
repo.file().delete(file).await?;
ctx.emit_to(Self::name(), "delete_file", ()).await?;
Ok(())
Ok(Response::empty())
}
/// Returns a list of available thumbnails of a file
#[tracing::instrument(skip_all)]
async fn thumbnails(ctx: &Context, event: Event) -> IPCResult<()> {
async fn thumbnails(ctx: &Context, event: Event) -> IPCResult<Response> {
let request = event.payload::<GetFileThumbnailsRequest>()?;
let repo = get_repo_from_context(ctx).await;
let file_cd = cd_by_identifier(request.id.clone(), &repo).await?;
@ -269,15 +240,13 @@ impl FilesNamespace {
.into_iter()
.map(ThumbnailMetadataResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "get_thumbnails", thumb_responses)
.await?;
Ok(())
ctx.response(thumb_responses)
}
/// Returns a thumbnail that is within the range of the requested sizes
#[tracing::instrument(skip_all)]
async fn get_thumbnail_of_size(ctx: &Context, event: Event) -> IPCResult<()> {
async fn get_thumbnail_of_size(ctx: &Context, event: Event) -> IPCResult<Response> {
let request = event.payload::<GetFileThumbnailOfSizeRequest>()?;
let repo = get_repo_from_context(ctx).await;
let file_cd = cd_by_identifier(request.id.clone(), &repo).await?;
@ -314,19 +283,13 @@ impl FilesNamespace {
thumbnail.get_reader().await?.read_to_end(&mut buf).await?;
let byte_payload = BytePayload::new(buf);
let thumb_payload = ThumbnailMetadataResponse::from_model(thumbnail);
ctx.emit_to(
Self::name(),
"get_thumbnail_of_size",
TandemPayload::new(thumb_payload, byte_payload),
)
.await?;
Ok(())
ctx.response(TandemPayload::new(thumb_payload, byte_payload))
}
/// Updates the name of a file
#[tracing::instrument(skip_all)]
async fn update_file_name(ctx: &Context, event: Event) -> IPCResult<()> {
async fn update_file_name(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let request = event.payload::<UpdateFileNameRequest>()?;
let file = file_by_identifier(request.file_id, &repo).await?;
@ -340,19 +303,12 @@ impl FilesNamespace {
})
.await?;
ctx.emit_to(
Self::name(),
"update_file_name",
FileMetadataResponse::from_model(metadata),
)
.await?;
Ok(())
ctx.response(FileMetadataResponse::from_model(metadata))
}
/// Deletes all thumbnails of a file
#[tracing::instrument(skip_all)]
async fn delete_thumbnails(ctx: &Context, event: Event) -> IPCResult<()> {
async fn delete_thumbnails(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let id = event.payload::<FileIdentifier>()?;
let file = file_by_identifier(id, &repo).await?;
@ -362,6 +318,6 @@ impl FilesNamespace {
thumb.delete().await?;
}
Ok(())
Ok(Response::empty())
}
}

@ -23,7 +23,7 @@ impl NamespaceProvider for JobsNamespace {
impl JobsNamespace {
#[tracing::instrument(skip_all)]
pub async fn run_job(ctx: &Context, event: Event) -> IPCResult<()> {
pub async fn run_job(ctx: &Context, event: Event) -> IPCResult<Response> {
let run_request = event.payload::<RunJobRequest>()?;
let job_dao = get_repo_from_context(ctx).await.job();
@ -34,9 +34,7 @@ impl JobsNamespace {
JobType::Vacuum => job_dao.vacuum().await?,
}
ctx.emit_to(Self::name(), "run_job", ()).await?;
Ok(())
Ok(Response::empty())
}
}

@ -23,7 +23,7 @@ impl NamespaceProvider for PresetsNamespace {
impl PresetsNamespace {
#[tracing::instrument(skip_all)]
pub async fn all_sorting_presets(ctx: &Context, _: Event) -> IPCResult<()> {
pub async fn all_sorting_presets(ctx: &Context, _: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let sorting_presets: Vec<SortingPreset> = repo
.sorting_preset()
@ -32,14 +32,12 @@ impl PresetsNamespace {
.into_iter()
.map(SortingPreset::from_model)
.collect();
ctx.emit_to(Self::name(), "all_sorting_presets", sorting_presets)
.await?;
Ok(())
ctx.response(sorting_presets)
}
#[tracing::instrument(skip_all)]
pub async fn add_sorting_preset(ctx: &Context, event: Event) -> IPCResult<()> {
pub async fn add_sorting_preset(ctx: &Context, event: Event) -> IPCResult<Response> {
let keys = event
.payload::<Vec<SortKey>>()?
.into_iter()
@ -50,25 +48,17 @@ impl PresetsNamespace {
.sorting_preset()
.add(AddSortingPresetDto { keys })
.await?;
ctx.emit_to(
Self::name(),
"add_sorting_preset",
SortingPreset::from_model(preset),
)
.await?;
Ok(())
ctx.response(SortingPreset::from_model(preset))
}
#[tracing::instrument(skip_all)]
pub async fn delete_sorting_preset(ctx: &Context, event: Event) -> IPCResult<()> {
pub async fn delete_sorting_preset(ctx: &Context, event: Event) -> IPCResult<Response> {
let id = event.payload::<i32>()?;
let repo = get_repo_from_context(ctx).await;
repo.sorting_preset().delete(id).await?;
ctx.emit_to(Self::name(), "delete_sorting_preset", ())
.await?;
Ok(())
Ok(Response::empty())
}
}

@ -29,7 +29,7 @@ impl NamespaceProvider for RepoNamespace {
impl RepoNamespace {
#[tracing::instrument(skip_all)]
async fn get_metadata(ctx: &Context, _: Event) -> IPCResult<()> {
async fn get_metadata(ctx: &Context, _: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let counts = repo.get_counts().await?;
@ -43,14 +43,12 @@ impl RepoNamespace {
};
tracing::debug!("metadata = {:?}", metadata);
ctx.emit_to(Self::name(), "repository_metadata", metadata)
.await?;
Ok(())
ctx.response(metadata)
}
#[tracing::instrument(skip_all)]
async fn get_size_metadata(ctx: &Context, event: Event) -> IPCResult<()> {
async fn get_size_metadata(ctx: &Context, event: Event) -> IPCResult<Response> {
let size_type = event.payload::<SizeType>()?;
let data = ctx.data.read().await;
let size_cache = data.get::<SizeMetadataKey>().unwrap();
@ -61,38 +59,25 @@ impl RepoNamespace {
calculate_size(&size_type, ctx).await?
};
ctx.emit_to(
Self::name(),
"size_metadata",
SizeMetadata { size, size_type },
)
.await?;
Ok(())
ctx.response(SizeMetadata { size, size_type })
}
#[tracing::instrument(skip_all)]
async fn frontend_state(ctx: &Context, _: Event) -> IPCResult<()> {
async fn frontend_state(ctx: &Context, _: Event) -> IPCResult<Response> {
let path = get_frontend_state_path(ctx).await?;
let state_string = if path.exists() {
Some(fs::read_to_string(path).await?)
} else {
None
};
ctx.emit_to(
Self::name(),
"frontend_state",
FrontendState {
state: state_string,
},
)
.await?;
Ok(())
ctx.response(FrontendState {
state: state_string,
})
}
#[tracing::instrument(skip_all)]
async fn set_frontend_state(ctx: &Context, event: Event) -> IPCResult<()> {
async fn set_frontend_state(ctx: &Context, event: Event) -> IPCResult<Response> {
let path = get_frontend_state_path(ctx).await?;
let state = event.payload::<FrontendState>()?.state;
if let Some(state_string) = state {
@ -101,7 +86,7 @@ impl RepoNamespace {
fs::remove_file(path).await?;
}
Ok(())
Ok(Response::empty())
}
}

@ -39,7 +39,7 @@ impl NamespaceProvider for TagsNamespace {
impl TagsNamespace {
/// Returns a list of all tags in the database
#[tracing::instrument(skip_all)]
async fn all_tags(ctx: &Context, _event: Event) -> IPCResult<()> {
async fn all_tags(ctx: &Context, _event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let tags: Vec<TagResponse> = repo
.tag()
@ -48,14 +48,13 @@ impl TagsNamespace {
.into_iter()
.map(TagResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "all_tags", tags).await?;
Ok(())
ctx.response(tags)
}
/// Returns a list of all namespaces from the database
#[tracing::instrument(skip_all)]
async fn all_namespaces(ctx: &Context, _event: Event) -> IPCResult<()> {
async fn all_namespaces(ctx: &Context, _event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let namespaces: Vec<NamespaceResponse> = repo
.tag()
@ -64,30 +63,25 @@ impl TagsNamespace {
.into_iter()
.map(NamespaceResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "all_namespaces", namespaces)
.await?;
Ok(())
ctx.response(namespaces)
}
/// Returns all tags for a single file
#[tracing::instrument(skip_all)]
async fn tags_for_file(ctx: &Context, event: Event) -> IPCResult<()> {
async fn tags_for_file(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let request = event.payload::<GetFileTagsRequest>()?;
let file = file_by_identifier(request.id, &repo).await?;
let tags = repo.tag().tags_for_cd(file.cd_id()).await?;
let responses: Vec<TagResponse> = tags.into_iter().map(TagResponse::from_model).collect();
ctx.emit_to(Self::name(), "tags_for_file", responses)
.await?;
Ok(())
ctx.response(responses)
}
/// Returns all tags for a given list of file hashes
#[tracing::instrument(skip_all)]
async fn tags_for_files(ctx: &Context, event: Event) -> IPCResult<()> {
async fn tags_for_files(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let request = event.payload::<GetFilesTagsRequest>()?;
let tag_responses: Vec<TagResponse> = repo
@ -103,15 +97,13 @@ impl TagsNamespace {
.into_iter()
.map(TagResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "tags_for_files", tag_responses)
.await?;
Ok(())
ctx.response(tag_responses)
}
/// Returns a map of content descriptors to assigned tags
#[tracing::instrument(skip_all)]
async fn tag_cd_map_for_files(ctx: &Context, event: Event) -> IPCResult<()> {
async fn tag_cd_map_for_files(ctx: &Context, event: Event) -> IPCResult<Response> {
let request = event.payload::<GetFileTagMapRequest>()?;
let repo = get_repo_from_context(ctx).await;
let cds = request
@ -136,14 +128,12 @@ impl TagsNamespace {
})
.collect::<HashMap<String, Vec<TagResponse>>>();
ctx.emit_to(Self::name(), "file_tag_map", mappings).await?;
Ok(())
ctx.response(mappings)
}
/// Creates all tags given as input or returns the existing tags
#[tracing::instrument(skip_all)]
async fn create_tags(ctx: &Context, event: Event) -> IPCResult<()> {
async fn create_tags(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let tags = event.payload::<Vec<String>>()?;
let created_tags = repo
@ -160,15 +150,14 @@ impl TagsNamespace {
.into_iter()
.map(TagResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "create_tags", responses).await?;
Ok(())
ctx.response(responses)
}
/// Changes tags of a file
/// it removes the tags from the removed list and adds the one from the add list
#[tracing::instrument(skip_all)]
async fn change_file_tags(ctx: &Context, event: Event) -> IPCResult<()> {
async fn change_file_tags(ctx: &Context, event: Event) -> IPCResult<Response> {
let repo = get_repo_from_context(ctx).await;
let request = event.payload::<ChangeFileTagsRequest>()?;
let file = file_by_identifier(request.file_id, &repo).await?;
@ -191,9 +180,7 @@ impl TagsNamespace {
.into_iter()
.map(TagResponse::from_model)
.collect();
ctx.emit_to(Self::name(), "change_file_tags", responses)
.await?;
Ok(())
ctx.response(responses)
}
}

@ -170,15 +170,16 @@ dependencies = [
[[package]]
name = "bromine"
version = "0.17.1"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6774171be092328d9631f246d3122f196a50ddaad224214ca274acec2a1db65d"
checksum = "5dd7887995490657bf3ec578f39e747ef7b5355a8dc6c99b3d5be59ca70dc4d5"
dependencies = [
"async-trait",
"bincode",
"byteorder",
"futures",
"futures-core",
"lazy_static",
"num_enum",
"serde",
"thiserror",
"tokio",
@ -809,9 +810,9 @@ dependencies = [
[[package]]
name = "futures"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4"
checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
dependencies = [
"futures-channel",
"futures-core",
@ -824,9 +825,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b"
checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
dependencies = [
"futures-core",
"futures-sink",
@ -834,15 +835,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7"
checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]]
name = "futures-executor"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a"
checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6"
dependencies = [
"futures-core",
"futures-task",
@ -851,9 +852,9 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2"
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]]
name = "futures-lite"
@ -872,9 +873,9 @@ dependencies = [
[[package]]
name = "futures-macro"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c"
checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
"proc-macro2 1.0.36",
"quote 1.0.15",
@ -883,21 +884,21 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508"
checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
[[package]]
name = "futures-task"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72"
checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
[[package]]
name = "futures-util"
version = "0.3.19"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164"
checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
dependencies = [
"futures-channel",
"futures-core",
@ -1499,7 +1500,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.28.1"
version = "0.29.0"
dependencies = [
"async-trait",
"bromine",
@ -1875,7 +1876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58"
dependencies = [
"lock_api",
"parking_lot_core 0.9.0",
"parking_lot_core 0.9.1",
]
[[package]]
@ -1894,9 +1895,9 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2f4f894f3865f6c0e02810fc597300f34dc2510f66400da262d8ae10e75767d"
checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954"
dependencies = [
"cfg-if 1.0.0",
"libc",
@ -3097,9 +3098,21 @@ dependencies = [
"once_cell",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
"proc-macro2 1.0.36",
"quote 1.0.15",
"syn 1.0.86",
]
[[package]]
name = "toml"
version = "0.5.8"
@ -3508,9 +3521,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceb069ac8b2117d36924190469735767f0990833935ab430155e71a44bafe148"
checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
@ -3521,33 +3534,33 @@ dependencies = [
[[package]]
name = "windows_aarch64_msvc"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d027175d00b01e0cbeb97d6ab6ebe03b12330a35786cbaca5252b1c4bf5d9b"
checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5"
[[package]]
name = "windows_i686_gnu"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8793f59f7b8e8b01eda1a652b2697d87b93097198ae85f823b969ca5b89bba58"
checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615"
[[package]]
name = "windows_i686_msvc"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8602f6c418b67024be2996c512f5f995de3ba417f4c75af68401ab8756796ae4"
checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172"
[[package]]
name = "windows_x86_64_gnu"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d615f419543e0bd7d2b3323af0d86ff19cbc4f816e6453f36a2c2ce889c354"
checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.29.0"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d95421d9ed3672c280884da53201a5c46b7b2765ca6faf34b0d71cf34a3561"
checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316"
[[package]]
name = "winres"

Loading…
Cancel
Save