From b5916e1d053525f7a4a7e16a31dfe4d6a41d2fc5 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Tue, 1 Dec 2020 21:09:32 +0100 Subject: [PATCH 1/2] set permission to 700 for directories --- src/rnote/notes.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/rnote/notes.rs b/src/rnote/notes.rs index 693f918..114abed 100644 --- a/src/rnote/notes.rs +++ b/src/rnote/notes.rs @@ -23,12 +23,25 @@ fn get_path(category: &str) -> Result { /// Create directory for a note. pub fn create_dir(category: &str) -> Result<()> { - let path = get_base_path()?; + let base = get_base_path()?; let date = Utc::now().format("%Y-%m-%d"); match category.is_empty() { - true => fs::create_dir_all(format!("{}{}", path, date))?, - false => fs::create_dir_all(format!("{}{}", path, category))?, + true => { + fs::create_dir_all(format!("{}{}", base, date))?; + fs::set_permissions( + format!("{}{}", base, date), + fs::Permissions::from_mode(0o700), + )?; + } + false => { + fs::create_dir_all(format!("{}{}", base, category))?; + fs::set_permissions( + format!("{}{}", base, category), + fs::Permissions::from_mode(0o700), + )?; + } } + fs::set_permissions(base, fs::Permissions::from_mode(0o700))?; Ok(()) } From 6f0a057cd068ebcd9972d5c2cc71566ac79e948a Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Tue, 1 Dec 2020 21:13:35 +0100 Subject: [PATCH 2/2] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f06804..9e136ba 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A minimal note taking cli tool. ## Description -**rnote** creates `Markdown` text files (with persission set to 600) in a date-named or category-named directories with a name of a header of the note. +**rnote** creates `Markdown` text files (with permissions set to 600) in a date-named or category-named directories (with permissions set to 700) with a name of a header of the note. Example: