Skip to content

Commit

Permalink
auto create sock dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AlkenePan committed Sep 22, 2022
1 parent 549229e commit ebe7e6f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rasp/rasp_server/src/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use log::*;
use bytes::Bytes;
use std::collections::HashMap;
use std::fs;
use std::fs::create_dir;
use std::os::unix::prelude::PermissionsExt;
use std::path::Path;
use std::sync::Arc;
Expand All @@ -27,6 +28,14 @@ pub fn clean_bind_addr(addr: &str) -> Result<(), String> {
Err(e) => return Err(e.to_string()),
}
}
if let Some(d) = Path::new(addr.clone()).parent() {
if !d.exists() {
match create_dir(d) {
Ok(_) => {},
Err(e) => return Err(format!("create dir failed: {:?} {}", d, e))
}
}
}
Ok(())
}

Expand Down

0 comments on commit ebe7e6f

Please sign in to comment.