refactor: move business logic out of presentation — ReadAssetFile, checksum, auth checks, MetadataValue conversions
This commit is contained in:
@@ -11,6 +11,7 @@ use domain::{
|
||||
},
|
||||
value_objects::{Checksum, DateTimeStamp, SystemId},
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
@@ -18,7 +19,6 @@ pub struct IngestAssetCommand {
|
||||
pub uploader_id: SystemId,
|
||||
pub client_device_id: String,
|
||||
pub filename: String,
|
||||
pub checksum: String,
|
||||
pub target_path_id: SystemId,
|
||||
pub file_size: u64,
|
||||
#[serde(skip)]
|
||||
@@ -60,7 +60,10 @@ impl IngestAssetHandler {
|
||||
&self,
|
||||
cmd: IngestAssetCommand,
|
||||
) -> Result<(Asset, IngestSession), DomainError> {
|
||||
let checksum = Checksum::new(&cmd.checksum)?;
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(&cmd.data);
|
||||
let checksum_hex = format!("{:x}", hasher.finalize());
|
||||
let checksum = Checksum::new(checksum_hex)?;
|
||||
|
||||
let path = self
|
||||
.path_repo
|
||||
|
||||
Reference in New Issue
Block a user