Skip to content

Commit

Permalink
Fixed parent directory being empty when only giving the output databa…
Browse files Browse the repository at this point in the history
…se name without parent directory
  • Loading branch information
pskvins committed Jan 10, 2025
1 parent e72e222 commit 6adce84
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/createdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::envs::variables as var;
use crate::envs::error_handler as err;
use crate::util::arg_parser::Args;
use crate::util::command as cmd;
use crate::util::message as msg;
use crate::util::checkpoint as chkpnt;

use std::io::{BufWriter, Write};
Expand Down Expand Up @@ -48,6 +49,10 @@ pub fn run(args: &Args, bin: &var::BinaryPaths) -> Result<(), Box<dyn std::error
} else {
err::error(err::ERR_GENERAL, Some("Could not obtain parent directory of the output".to_string()))
};
// If the parent directory is empty, set it to '.'
let parent = if parent.is_empty() { ".".to_string() } else { parent };
// Print the parent directory
msg::println_message(&format!("Parent directory: {}", parent), 4);
// If the parent directory of the output doesn't exist, make one
if !Path::new(&parent).exists() {
std::fs::create_dir_all(&parent)?;
Expand Down

0 comments on commit 6adce84

Please sign in to comment.