Change file id variant CID to CD

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 77241ebc2d
commit b315024c6a

@ -1,6 +1,6 @@
[package] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.21.0" version = "0.22.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"

@ -122,10 +122,7 @@ pub async fn read_file(
Ok(buffer.buf) Ok(buffer.buf)
} else { } else {
let api = api_state.api().await?; let api = api_state.api().await?;
let content = api let content = api.file.read_file(FileIdentifier::CD(hash.clone())).await?;
.file
.read_file(FileIdentifier::CID(hash.clone()))
.await?;
Ok(content) Ok(content)
} }

@ -69,12 +69,12 @@ async fn content_scheme<R: Runtime>(app: &AppHandle<R>, request: &Request) -> Re
let api = api_state.api().await?; let api = api_state.api().await?;
let file = api let file = api
.file .file
.get_file(FileIdentifier::CID(hash.to_string())) .get_file(FileIdentifier::CD(hash.to_string()))
.await?; .await?;
let mime = file.mime_type; let mime = file.mime_type;
let bytes = api let bytes = api
.file .file
.read_file(FileIdentifier::CID(hash.to_string())) .read_file(FileIdentifier::CD(hash.to_string()))
.await?; .await?;
tracing::debug!("Received {} content bytes", bytes.len()); tracing::debug!("Received {} content bytes", bytes.len());
buf_state.add_entry(hash.to_string(), mime.clone(), bytes.clone()); buf_state.add_entry(hash.to_string(), mime.clone(), bytes.clone());
@ -121,7 +121,7 @@ async fn thumb_scheme<R: Runtime>(app: &AppHandle<R>, request: &Request) -> Resu
let (thumb, bytes) = api let (thumb, bytes) = api
.file .file
.get_thumbnail_of_size( .get_thumbnail_of_size(
FileIdentifier::CID(hash.to_string()), FileIdentifier::CD(hash.to_string()),
((height as f32 * 0.8) as u32, (width as f32 * 0.8) as u32), ((height as f32 * 0.8) as u32, (width as f32 * 0.8) as u32),
((height as f32 * 1.2) as u32, (width as f32 * 1.2) as u32), ((height as f32 * 1.2) as u32, (width as f32 * 1.2) as u32),
) )

@ -3,5 +3,5 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub enum FileIdentifier { pub enum FileIdentifier {
ID(i64), ID(i64),
CID(String), CD(String),
} }

Loading…
Cancel
Save