1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-06-27 16:35:59 +00:00

refactor: Create the directory for media only if the directory_structure is Deep

This commit is contained in:
AndSDev 2025-06-10 15:13:58 +03:00
parent 4982aa1098
commit 39c09f865a

View file

@ -681,8 +681,10 @@ pub async fn create_file(sha256_hex: &str, file: &[u8]) -> Result<()> {
.get_media_path(path, directory_structure, sha256_hex)?; .get_media_path(path, directory_structure, sha256_hex)?;
// Create all directories leading up to file // Create all directories leading up to file
if let Some(parent) = path.parent() { if let DirectoryStructure::Deep { .. } = directory_structure {
fs::create_dir_all(&parent).await.inspect_err(|e| error!("Error creating leading directories for media with sha256 hash of {sha256_hex}: {e}"))?; if let Some(parent) = path.parent() {
fs::create_dir_all(&parent).await.inspect_err(|e| error!("Error creating leading directories for media with sha256 hash of {sha256_hex}: {e}"))?;
}
} }
let mut f = File::create(path).await?; let mut f = File::create(path).await?;