Skip to content

Commit

Permalink
Merge pull request #209 from lancelui-amzn/record-temp-folder
Browse files Browse the repository at this point in the history
Add error message for fail to create record temp folder
  • Loading branch information
lancelui-amzn authored Jul 26, 2024
2 parents 7105bec + bc8b995 commit a5df597
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{data, InitParams, PERFORMANCE_DATA};
use anyhow::Result;
use clap::Args;
use log::{debug, error, info};
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::{fs, process};

pub static APERF_TMP: &str = "/tmp/aperf_tmp";

Expand Down Expand Up @@ -88,7 +88,10 @@ pub fn record(record: &Record) -> Result<()> {
}

fs::remove_dir_all(APERF_TMP).ok();
fs::create_dir(APERF_TMP)?;
if let Err(e) = fs::create_dir(APERF_TMP) {
error!("Could not create /tmp/aperf_tmp folder.\n{}: Remove using 'sudo rm -rf /tmp/aperf_tmp'.", e);
process::exit(1);
}
let mut perms: fs::Permissions = fs::metadata(APERF_TMP)?.permissions();
perms.set_mode(0o777);
fs::set_permissions(APERF_TMP, perms)?;
Expand Down

0 comments on commit a5df597

Please sign in to comment.