Fix problems with logging binary data

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent de0f6fcbdf
commit 90eae0bc16

@ -297,6 +297,9 @@ impl File {
/// Adds multiple tags to the file at once /// Adds multiple tags to the file at once
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn add_tags(&self, tag_ids: Vec<i64>) -> RepoResult<()> { pub async fn add_tags(&self, tag_ids: Vec<i64>) -> RepoResult<()> {
if tag_ids.is_empty() {
return Ok(());
}
let hash_id = self.hash.id; let hash_id = self.hash.id;
let models: Vec<hash_tag::ActiveModel> = tag_ids let models: Vec<hash_tag::ActiveModel> = tag_ids
.into_iter() .into_iter()

@ -132,7 +132,7 @@ impl Repo {
} }
/// Adds a file from bytes to the database /// 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( pub async fn add_file(
&self, &self,
mime_type: Option<String>, mime_type: Option<String>,

@ -13,7 +13,8 @@ use mediarepo_core::utils::parse_namespace_and_tag;
use mediarepo_database::queries::tags::get_hashes_with_namespaced_tags; use mediarepo_database::queries::tags::get_hashes_with_namespaced_tags;
use mediarepo_model::file::File; use mediarepo_model::file::File;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
pub struct FilesNamespace; pub struct FilesNamespace;
@ -111,6 +112,7 @@ impl FilesNamespace {
.await?; .await?;
file.set_name(metadata.name).await?; file.set_name(metadata.name).await?;
let tags: HashSet<String> = HashSet::from_iter(tags.into_iter());
let tags = repo let tags = repo
.add_all_tags(tags.into_iter().map(parse_namespace_and_tag).collect()) .add_all_tags(tags.into_iter().map(parse_namespace_and_tag).collect())
.await?; .await?;

Loading…
Cancel
Save