diff --git a/mediarepo-daemon/Cargo.lock b/mediarepo-daemon/Cargo.lock index 40a29d0..3ffed93 100644 --- a/mediarepo-daemon/Cargo.lock +++ b/mediarepo-daemon/Cargo.lock @@ -855,8 +855,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "mediarepo-api" -version = "0.6.0" -source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=ddebf4bf0c3e96ede64182ff52bd84f134acc33a#ddebf4bf0c3e96ede64182ff52bd84f134acc33a" +version = "0.7.0" +source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=3275c328fa6ac362f71fc548301b7c7c70725ca8#3275c328fa6ac362f71fc548301b7c7c70725ca8" dependencies = [ "chrono", "serde", diff --git a/mediarepo-daemon/mediarepo-socket/Cargo.lock b/mediarepo-daemon/mediarepo-socket/Cargo.lock index c7d7bf0..bc5dcde 100644 --- a/mediarepo-daemon/mediarepo-socket/Cargo.lock +++ b/mediarepo-daemon/mediarepo-socket/Cargo.lock @@ -796,8 +796,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "mediarepo-api" -version = "0.6.0" -source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=ddebf4bf0c3e96ede64182ff52bd84f134acc33a#ddebf4bf0c3e96ede64182ff52bd84f134acc33a" +version = "0.7.0" +source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=3275c328fa6ac362f71fc548301b7c7c70725ca8#3275c328fa6ac362f71fc548301b7c7c70725ca8" dependencies = [ "chrono", "serde", diff --git a/mediarepo-daemon/mediarepo-socket/Cargo.toml b/mediarepo-daemon/mediarepo-socket/Cargo.toml index 242db0e..beca3fd 100644 --- a/mediarepo-daemon/mediarepo-socket/Cargo.toml +++ b/mediarepo-daemon/mediarepo-socket/Cargo.toml @@ -34,4 +34,4 @@ features = ["tokio-executor"] [dependencies.mediarepo-api] git = "https://github.com/Trivernis/mediarepo-api.git" -rev = "ddebf4bf0c3e96ede64182ff52bd84f134acc33a" \ No newline at end of file +rev = "3275c328fa6ac362f71fc548301b7c7c70725ca8" \ No newline at end of file diff --git a/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs b/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs index 8ad1ba4..773a7de 100644 --- a/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs +++ b/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs @@ -6,6 +6,7 @@ use mediarepo_api::types::files::{ GetFileThumbnailOfSizeRequest, GetFileThumbnailsRequest, ReadFileRequest, SortDirection, SortKey, ThumbnailMetadataResponse, UpdateFileNameRequest, }; +use mediarepo_api::types::identifier::FileIdentifier; use mediarepo_core::error::RepoError; use mediarepo_core::itertools::Itertools; use mediarepo_core::rmp_ipc::prelude::*; @@ -27,6 +28,7 @@ impl NamespaceProvider for FilesNamespace { fn register(handler: &mut EventHandler) { events!(handler, "all_files" => Self::all_files, + "get_file" => Self::get_file, "find_files" => Self::find_files, "add_file" => Self::add_file, "read_file" => Self::read_file, @@ -57,6 +59,20 @@ impl FilesNamespace { Ok(()) } + /// Returns a file by id + #[tracing::instrument(skip_all)] + async fn get_file(ctx: &Context, event: Event) -> IPCResult<()> { + let id = event.data::()?; + let repo = get_repo_from_context(ctx).await; + let file = file_by_identifier(id, &repo).await?; + let response = FileMetadataResponse::from_model(file); + ctx.emitter + .emit_response_to(event.id(), Self::name(), "get_file", response) + .await?; + + Ok(()) + } + /// Searches for files by tags #[tracing::instrument(skip_all)] async fn find_files(ctx: &Context, event: Event) -> IPCResult<()> {