Skip to content

Commit

Permalink
💄 Improved function names for dotfile searching
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario-SO committed Jun 30, 2024
1 parent d7812e1 commit 7f01167
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::lock::{
};
use crate::utils::{
get_current_working_dir,
check_for_sensitive_files_or_directories_recursive,
check_dotfiles_recursive,
prompt_user_for_confirmation
};
use crate::versioning::push_version;
Expand Down Expand Up @@ -279,7 +279,7 @@ pub async fn run(command: Subcommands) -> Result<(), SoldeerError> {
let path_buf = PathBuf::from(&path);

// Check for sensitive files or directories
if check_for_sensitive_files_or_directories_recursive(&path_buf) {
if check_dotfiles_recursive(&path_buf) {
if !prompt_user_for_confirmation() {
println!("{}", Paint::yellow("Push operation aborted by the user."));
return Ok(());
Expand Down
8 changes: 4 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn get_base_url() -> String {
}

// Function to check for the presence of sensitive files or directories
pub fn check_for_sensitive_files_or_directories(path: &Path) -> bool {
pub fn check_dotfiles(path: &Path) -> bool {
if let Ok(entries) = fs::read_dir(path) {
for entry in entries {
if let Ok(entry) = entry {
Expand All @@ -135,16 +135,16 @@ pub fn check_for_sensitive_files_or_directories(path: &Path) -> bool {
}

// Function to recursively check for sensitive files or directories in a given path
pub fn check_for_sensitive_files_or_directories_recursive(path: &Path) -> bool {
if check_for_sensitive_files_or_directories(path) {
pub fn check_dotfiles_recursive(path: &Path) -> bool {
if check_dotfiles(path) {
return true;
}

if path.is_dir() {
for entry in fs::read_dir(path).unwrap() {
let entry = entry.unwrap();
let entry_path = entry.path();
if check_for_sensitive_files_or_directories_recursive(&entry_path) {
if check_dotfiles_recursive(&entry_path) {
return true;
}
}
Expand Down

0 comments on commit 7f01167

Please sign in to comment.