aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/utils
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-07 15:40:04 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-07 15:42:00 +0530
commit2446aec82c9446638027ced2ae3a22cc1e6e5bee (patch)
tree64bf9fc8ea7258e6e3e16ecfc1033110f7c4171f /src/common/utils
parentfix(build): Make sure `assets/man` folder exists before building (diff)
downloadsl0ppij-2446aec82c9446638027ced2ae3a22cc1e6e5bee.tar.gz
sl0ppij-2446aec82c9446638027ced2ae3a22cc1e6e5bee.tar.xz
sl0ppij-2446aec82c9446638027ced2ae3a22cc1e6e5bee.zip
hotfix(logging): fix atomic_create_file and make set_permissions() return an error
Diffstat (limited to 'src/common/utils')
-rw-r--r--src/common/utils/consts.rs2
-rw-r--r--src/common/utils/logging.rs14
2 files changed, 10 insertions, 6 deletions
diff --git a/src/common/utils/consts.rs b/src/common/utils/consts.rs
index a46f8243..bc8768ce 100644
--- a/src/common/utils/consts.rs
+++ b/src/common/utils/consts.rs
@@ -30,7 +30,7 @@ lazy_static! {
);
ipc_dir.push(VERSION);
fs::create_dir_all(&ipc_dir).unwrap();
- set_permissions(&ipc_dir);
+ set_permissions(&ipc_dir).unwrap();
ipc_dir.push(&*SESSION_NAME);
ipc_dir
};
diff --git a/src/common/utils/logging.rs b/src/common/utils/logging.rs
index ff3fb44c..4c53e2b2 100644
--- a/src/common/utils/logging.rs
+++ b/src/common/utils/logging.rs
@@ -11,9 +11,13 @@ use crate::os_input_output::set_permissions;
use crate::utils::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
pub fn atomic_create_file(file_name: &Path) {
- let _ = fs::OpenOptions::new().create(true).open(file_name);
+ let _ = fs::OpenOptions::new()
+ .append(true)
+ .create(true)
+ .open(file_name)
+ .unwrap();
#[cfg(not(test))]
- set_permissions(file_name);
+ set_permissions(file_name).unwrap();
}
pub fn atomic_create_dir(dir_name: &Path) -> io::Result<()> {
@@ -27,7 +31,7 @@ pub fn atomic_create_dir(dir_name: &Path) -> io::Result<()> {
Ok(())
};
if result.is_ok() {
- set_permissions(dir_name);
+ set_permissions(dir_name)?;
}
result
}
@@ -41,7 +45,6 @@ pub fn debug_log_to_file_without_newline(message: String) -> io::Result<()> {
atomic_create_file(&*ZELLIJ_TMP_LOG_FILE);
let mut file = fs::OpenOptions::new()
.append(true)
- .create(true)
.open(&*ZELLIJ_TMP_LOG_FILE)?;
file.write_all(message.as_bytes())
}
@@ -78,6 +81,7 @@ pub fn debug_to_file(message: u8, pid: RawFd) -> io::Result<()> {
let mut file = fs::OpenOptions::new()
.append(true)
.create(true)
- .open(path)?;
+ .open(&path)?;
+ set_permissions(&path)?;
file.write_all(&[message])
}