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:
parent
4982aa1098
commit
39c09f865a
1 changed files with 4 additions and 2 deletions
|
@ -681,9 +681,11 @@ pub async fn create_file(sha256_hex: &str, file: &[u8]) -> Result<()> {
|
|||
.get_media_path(path, directory_structure, sha256_hex)?;
|
||||
|
||||
// Create all directories leading up to file
|
||||
if let DirectoryStructure::Deep { .. } = directory_structure {
|
||||
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?;
|
||||
f.write_all(file).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue