From 90eae0bc165d145ccda3d0fee5717fafc54dac53 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 9 Nov 2021 21:20:30 +0100 Subject: [PATCH] Fix problems with logging binary data Signed-off-by: trivernis --- mediarepo-daemon/mediarepo-model/src/file.rs | 3 +++ mediarepo-daemon/mediarepo-model/src/repo.rs | 2 +- mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mediarepo-daemon/mediarepo-model/src/file.rs b/mediarepo-daemon/mediarepo-model/src/file.rs index c28e6fe..a1cfbab 100644 --- a/mediarepo-daemon/mediarepo-model/src/file.rs +++ b/mediarepo-daemon/mediarepo-model/src/file.rs @@ -297,6 +297,9 @@ impl File { /// Adds multiple tags to the file at once #[tracing::instrument(level = "debug", skip(self))] pub async fn add_tags(&self, tag_ids: Vec) -> RepoResult<()> { + if tag_ids.is_empty() { + return Ok(()); + } let hash_id = self.hash.id; let models: Vec = tag_ids .into_iter() diff --git a/mediarepo-daemon/mediarepo-model/src/repo.rs b/mediarepo-daemon/mediarepo-model/src/repo.rs index 8a45919..e71fcb9 100644 --- a/mediarepo-daemon/mediarepo-model/src/repo.rs +++ b/mediarepo-daemon/mediarepo-model/src/repo.rs @@ -132,7 +132,7 @@ impl Repo { } /// Adds a file from bytes to the database - #[tracing::instrument(level = "debug", skip(self))] + #[tracing::instrument(level = "debug", skip(self, content))] pub async fn add_file( &self, mime_type: Option, diff --git a/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs b/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs index e3c20ba..2bf0333 100644 --- a/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs +++ b/mediarepo-daemon/mediarepo-socket/src/namespaces/files.rs @@ -13,7 +13,8 @@ use mediarepo_core::utils::parse_namespace_and_tag; use mediarepo_database::queries::tags::get_hashes_with_namespaced_tags; use mediarepo_model::file::File; use std::cmp::Ordering; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; +use std::iter::FromIterator; use tokio::io::AsyncReadExt; pub struct FilesNamespace; @@ -111,6 +112,7 @@ impl FilesNamespace { .await?; file.set_name(metadata.name).await?; + let tags: HashSet = HashSet::from_iter(tags.into_iter()); let tags = repo .add_all_tags(tags.into_iter().map(parse_namespace_and_tag).collect()) .await?;