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] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.28.1" version = "0.29.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"
@ -15,12 +15,12 @@ serde_json = { version = "1.0.78", optional = true }
directories = { version = "4.0.1", optional = true } directories = { version = "4.0.1", optional = true }
mime_guess = { version = "2.0.3", optional = true } mime_guess = { version = "2.0.3", optional = true }
serde_piecewise_default = "0.2.0" 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 } url = { version = "2.2.2", optional = true }
pathsearch = { version = "0.2.0", optional = true } pathsearch = { version = "0.2.0", optional = true }
[dependencies.bromine] [dependencies.bromine]
version = "0.17.1" version = "0.18.1"
optional = true optional = true
features = ["serialize_bincode"] features = ["serialize_bincode"]

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

@ -27,14 +27,17 @@ impl JobApi {
/// Runs a job of the given type and returns when it has finished /// Runs a job of the given type and returns when it has finished
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn run_job(&self, job_type: JobType) -> ApiResult<()> { pub async fn run_job(&self, job_type: JobType) -> ApiResult<()> {
self.emit_and_get( self.emit(
"run_job", "run_job",
RunJobRequest { RunJobRequest {
job_type, job_type,
sync: true, 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::client_api::tag::TagApi;
use crate::types::misc::{check_apis_compatible, get_api_version, InfoResponse}; use crate::types::misc::{check_apis_compatible, get_api_version, InfoResponse};
use async_trait::async_trait; use async_trait::async_trait;
use bromine::ipc::stream_emitter::EmitMetadata;
use bromine::prelude::*; use bromine::prelude::*;
use bromine::prelude::emit_metadata::EmitMetadata;
use tokio::time::Duration; use tokio::time::Duration;
use crate::client_api::preset::PresetApi; use crate::client_api::preset::PresetApi;
@ -84,12 +84,14 @@ impl ApiClient {
pub async fn connect<L: AsyncStreamProtocolListener>( pub async fn connect<L: AsyncStreamProtocolListener>(
address: L::AddressType, address: L::AddressType,
) -> ApiResult<Self> { ) -> ApiResult<Self> {
tracing::debug!("Connecting to {:?}", address);
let ctx = IPCBuilder::<L>::new() let ctx = IPCBuilder::<L>::new()
.address(address) .address(address)
.timeout(Duration::from_secs(10)) .timeout(Duration::from_secs(10))
.build_pooled_client(8) .build_pooled_client(8)
.await?; .await?;
let client = Self::new(ctx); let client = Self::new(ctx);
tracing::debug!("Retrieving info on daemon version...");
let info = client.info().await?; let info = client.info().await?;
let server_api_version = info.api_version(); let server_api_version = info.api_version();
@ -113,6 +115,8 @@ impl ApiClient {
pub async fn info(&self) -> ApiResult<InfoResponse> { pub async fn info(&self) -> ApiResult<InfoResponse> {
let ctx = self.ctx.acquire(); let ctx = self.ctx.acquire();
let res = ctx.emit("info", ()).await_reply().await?; let res = ctx.emit("info", ()).await_reply().await?;
tracing::trace!("Got info event {:?}", res);
Ok(res.payload::<InfoResponse>()?) 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 super::IPCApi;
use crate::client_api::error::ApiResult;
use crate::types::filtering::{SortKey, SortingPreset};
use bromine::prelude::*;
use std::time::Duration;
#[derive(Clone)] #[derive(Clone)]
pub struct PresetApi { pub struct PresetApi {
@ -27,28 +27,22 @@ impl PresetApi {
/// Returns all sorting presets of the repository /// Returns all sorting presets of the repository
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn all_sorting_presets(&self) -> ApiResult<Vec<SortingPreset>> { pub async fn all_sorting_presets(&self) -> ApiResult<Vec<SortingPreset>> {
self.emit_and_get( self.emit_and_get("all_sorting_presets", (), Some(Duration::from_secs(1)))
"all_sorting_presets",
(),
Some(Duration::from_secs(1))
)
.await .await
} }
/// Adds a new sorting preset with the given keys /// Adds a new sorting preset with the given keys
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn add_sorting_preset(&self, keys: Vec<SortKey>) -> ApiResult<SortingPreset> { pub async fn add_sorting_preset(&self, keys: Vec<SortKey>) -> ApiResult<SortingPreset> {
self.emit_and_get( self.emit_and_get("add_sorting_preset", keys, Some(Duration::from_secs(1)))
"add_sorting_preset",
keys,
Some(Duration::from_secs(1))
)
.await .await
} }
/// Deletes a given sorting preset by id /// Deletes a given sorting preset by id
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn delete_sorting_preset(&self, id: i32) -> ApiResult<()> { 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]] [[package]]
name = "bromine" name = "bromine"
version = "0.17.1" version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6774171be092328d9631f246d3122f196a50ddaad224214ca274acec2a1db65d" checksum = "5dd7887995490657bf3ec578f39e747ef7b5355a8dc6c99b3d5be59ca70dc4d5"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bincode", "bincode",
"byteorder", "byteorder",
"futures 0.3.19", "futures-core",
"lazy_static", "lazy_static",
"num_enum",
"serde 1.0.136", "serde 1.0.136",
"thiserror", "thiserror",
"tokio", "tokio",
@ -428,7 +429,7 @@ checksum = "829835c211a0247cd11e65e13cec8696b879374879c35ce162ce8098b23c90d4"
dependencies = [ dependencies = [
"console-api", "console-api",
"crossbeam-channel", "crossbeam-channel",
"futures 0.3.19", "futures 0.3.21",
"hdrhistogram", "hdrhistogram",
"humantime", "humantime",
"serde 1.0.136", "serde 1.0.136",
@ -840,9 +841,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -855,9 +856,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -865,15 +866,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]] [[package]]
name = "futures-executor" name = "futures-executor"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-task", "futures-task",
@ -893,15 +894,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.36",
"quote 1.0.15", "quote 1.0.15",
@ -910,21 +911,21 @@ dependencies = [
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.19" version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -1360,7 +1361,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.28.1" version = "0.29.0"
dependencies = [ dependencies = [
"bromine", "bromine",
"chrono", "chrono",
@ -1377,7 +1378,7 @@ dependencies = [
"base64", "base64",
"config", "config",
"data-encoding", "data-encoding",
"futures 0.3.19", "futures 0.3.21",
"glob", "glob",
"itertools", "itertools",
"mediarepo-api", "mediarepo-api",
@ -1708,6 +1709,27 @@ dependencies = [
"libc", "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]] [[package]]
name = "num_threads" name = "num_threads"
version = "0.1.3" version = "0.1.3"
@ -2196,14 +2218,14 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "sea-orm" name = "sea-orm"
version = "0.5.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5452736ac11d11f9dcf1980897d3a6302d78ee2bfcb928b0f9c03569f2e6b12c" checksum = "dd24380b48dacd3ed1c3d467c7b17ffa5818555a2c04066f4a0a9e17d830abc9"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"chrono", "chrono",
"futures 0.3.19", "futures 0.3.21",
"futures-util", "futures-util",
"once_cell", "once_cell",
"ouroboros", "ouroboros",
@ -2221,9 +2243,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-orm-macros" name = "sea-orm-macros"
version = "0.5.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8b7b6d423b591bf447685e9ea7cecd65e0c282e18dc5ddc7438425cd296faa8" checksum = "c199fa8630b1e195d7aef24ce8944af8f4ced67c4eccffd8926453b59f2565a1"
dependencies = [ dependencies = [
"bae", "bae",
"heck", "heck",
@ -2234,9 +2256,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-query" name = "sea-query"
version = "0.20.0" version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83e4a0dd79545b61c6ca453a28d0a88829487869a8559a35a3192f1b6aacad8" checksum = "9088ff96158860a75d98a85a654fdd9d97b10515773af6d87339bfc48258c800"
dependencies = [ dependencies = [
"chrono", "chrono",
"rust_decimal", "rust_decimal",
@ -2812,7 +2834,7 @@ checksum = "d08ebea7dc6b22273290d8ece2ca448f979f836e38ba629b650595c64204b4f2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-recursion", "async-recursion",
"futures 0.3.19", "futures 0.3.21",
"log", "log",
"tokio", "tokio",
"tokio-util", "tokio-util",

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

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

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

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

@ -1,12 +1,12 @@
use sea_orm::ConnectionTrait;
use sea_orm::prelude::*; use sea_orm::prelude::*;
use sea_orm::TransactionTrait;
use mediarepo_core::error::{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 crate::dao::file::{FileDao}; use crate::dao::file::FileDao;
use crate::dto::FileDto; use crate::dto::FileDto;
impl FileDao { impl FileDao {

@ -4,7 +4,7 @@ use std::str::FromStr;
use sea_orm::prelude::*; use sea_orm::prelude::*;
use sea_orm::ActiveValue::{Set, Unchanged}; 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::error::{RepoError, RepoResult};
use mediarepo_core::fs::thumbnail_store::Dimensions; use mediarepo_core::fs::thumbnail_store::Dimensions;

@ -6,7 +6,7 @@ use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::content_descriptor; use mediarepo_database::entities::content_descriptor;
use sea_orm::prelude::*; use sea_orm::prelude::*;
use sea_orm::ActiveValue::Set; use sea_orm::ActiveValue::Set;
use sea_orm::ConnectionTrait; use sea_orm::TransactionTrait;
impl JobDao { impl JobDao {
#[tracing::instrument(level = "debug", skip(self))] #[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::prelude::*;
use sea_orm::ActiveValue::Set; use sea_orm::ActiveValue::Set;
use sea_orm::{ use sea_orm::{
Condition, ConnectionTrait, DatabaseTransaction, DbBackend, FromQueryResult, JoinType, Condition, DatabaseTransaction, DbBackend, FromQueryResult, JoinType, QuerySelect, Statement,
QuerySelect, Statement, TransactionTrait,
}; };
#[allow(unused_imports)] #[allow(unused_imports)]

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

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

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

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

@ -23,7 +23,7 @@ impl NamespaceProvider for PresetsNamespace {
impl PresetsNamespace { impl PresetsNamespace {
#[tracing::instrument(skip_all)] #[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 repo = get_repo_from_context(ctx).await;
let sorting_presets: Vec<SortingPreset> = repo let sorting_presets: Vec<SortingPreset> = repo
.sorting_preset() .sorting_preset()
@ -32,14 +32,12 @@ impl PresetsNamespace {
.into_iter() .into_iter()
.map(SortingPreset::from_model) .map(SortingPreset::from_model)
.collect(); .collect();
ctx.emit_to(Self::name(), "all_sorting_presets", sorting_presets)
.await?;
Ok(()) ctx.response(sorting_presets)
} }
#[tracing::instrument(skip_all)] #[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 let keys = event
.payload::<Vec<SortKey>>()? .payload::<Vec<SortKey>>()?
.into_iter() .into_iter()
@ -50,25 +48,17 @@ impl PresetsNamespace {
.sorting_preset() .sorting_preset()
.add(AddSortingPresetDto { keys }) .add(AddSortingPresetDto { keys })
.await?; .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)] #[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 id = event.payload::<i32>()?;
let repo = get_repo_from_context(ctx).await; let repo = get_repo_from_context(ctx).await;
repo.sorting_preset().delete(id).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 { impl RepoNamespace {
#[tracing::instrument(skip_all)] #[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 repo = get_repo_from_context(ctx).await;
let counts = repo.get_counts().await?; let counts = repo.get_counts().await?;
@ -43,14 +43,12 @@ impl RepoNamespace {
}; };
tracing::debug!("metadata = {:?}", metadata); tracing::debug!("metadata = {:?}", metadata);
ctx.emit_to(Self::name(), "repository_metadata", metadata)
.await?;
Ok(()) ctx.response(metadata)
} }
#[tracing::instrument(skip_all)] #[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 size_type = event.payload::<SizeType>()?;
let data = ctx.data.read().await; let data = ctx.data.read().await;
let size_cache = data.get::<SizeMetadataKey>().unwrap(); let size_cache = data.get::<SizeMetadataKey>().unwrap();
@ -61,38 +59,25 @@ impl RepoNamespace {
calculate_size(&size_type, ctx).await? calculate_size(&size_type, ctx).await?
}; };
ctx.emit_to( ctx.response(SizeMetadata { size, size_type })
Self::name(),
"size_metadata",
SizeMetadata { size, size_type },
)
.await?;
Ok(())
} }
#[tracing::instrument(skip_all)] #[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 path = get_frontend_state_path(ctx).await?;
let state_string = if path.exists() { let state_string = if path.exists() {
Some(fs::read_to_string(path).await?) Some(fs::read_to_string(path).await?)
} else { } else {
None None
}; };
ctx.emit_to(
Self::name(),
"frontend_state",
FrontendState {
state: state_string,
},
)
.await?;
Ok(()) ctx.response(FrontendState {
state: state_string,
})
} }
#[tracing::instrument(skip_all)] #[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 path = get_frontend_state_path(ctx).await?;
let state = event.payload::<FrontendState>()?.state; let state = event.payload::<FrontendState>()?.state;
if let Some(state_string) = state { if let Some(state_string) = state {
@ -101,7 +86,7 @@ impl RepoNamespace {
fs::remove_file(path).await?; fs::remove_file(path).await?;
} }
Ok(()) Ok(Response::empty())
} }
} }

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

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

Loading…
Cancel
Save