Merge branch 'perm' into 'main'
set permission to 700 for directories See merge request paris8-rust/rnote!7
This commit is contained in:
		
						commit
						fce453c53a
					
				@ -5,7 +5,7 @@ A minimal note taking cli tool.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Description
 | 
					## 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:
 | 
					Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -23,12 +23,25 @@ fn get_path(category: &str) -> Result<String> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/// Create directory for a note.
 | 
					/// Create directory for a note.
 | 
				
			||||||
pub fn create_dir(category: &str) -> Result<()> {
 | 
					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");
 | 
					    let date = Utc::now().format("%Y-%m-%d");
 | 
				
			||||||
    match category.is_empty() {
 | 
					    match category.is_empty() {
 | 
				
			||||||
        true => fs::create_dir_all(format!("{}{}", path, date))?,
 | 
					        true => {
 | 
				
			||||||
        false => fs::create_dir_all(format!("{}{}", path, category))?,
 | 
					            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(())
 | 
					    Ok(())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user