Skip to content

Commit e43249c

Browse files
esarverrajeshwari-kiwad
andauthored
fix: add message when unable to create script file (#47)
Co-authored-by: rajeshwari-kiwad <[email protected]>
1 parent 8b8e908 commit e43249c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

kic-script-gen/src/back_end/client_server.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::path::Path;
1717

1818
use super::data_model::DataModel;
1919
use crate::back_end::ipc_data::IpcData;
20+
use script_gen_manager::model::sweep_data::status_msg::{StatusMsg, StatusType};
2021

2122
#[derive(Serialize, Deserialize)]
2223
pub struct ScriptPath {
@@ -77,17 +78,20 @@ impl AppState {
7778
// Check if the folder exists and is writable
7879

7980
if folder.exists() {
80-
let permissions = folder.metadata().map(|m| m.permissions()).unwrap();
81-
if permissions.readonly() {
82-
println!("Cannot update work folder: folder is read-only");
83-
return;
84-
}
8581
*work_folder_guard = Some(path_file.to_string_lossy().to_string());
8682
println!("Work folder updated to: {work_folder_guard:?}");
8783
} else {
84+
let status_msg = StatusMsg::new(
85+
StatusType::Error,
86+
format!(
87+
"The folder is read-only (OR) Work folder does not exist: {:?}",
88+
path_file.to_string_lossy().to_string()
89+
),
90+
);
8891
println!(
89-
"Work folder does not exist: {:?}",
90-
path_file.to_string_lossy().to_string()
92+
"{}",
93+
serde_json::to_string(&status_msg)
94+
.unwrap_or_else(|_| status_msg.message.clone())
9195
);
9296
}
9397
} else {

0 commit comments

Comments
 (0)