diff --git a/src/action/base/create_or_insert_into_file.rs b/src/action/base/create_or_insert_into_file.rs index 9afe1f6..323e71f 100644 --- a/src/action/base/create_or_insert_into_file.rs +++ b/src/action/base/create_or_insert_into_file.rs @@ -79,11 +79,12 @@ impl CreateOrInsertIntoFile { let discovered_mode = discovered_mode & 0o777; if discovered_mode != mode { - return Err(ActionError::PathModeMismatch( - this.path.clone(), + tracing::debug!( + "`{}` has mode `{}`, a mode of `{}` was expected", + this.path.display(), discovered_mode, mode, - )); + ); } } @@ -459,17 +460,19 @@ mod test { } #[tokio::test] - async fn recognizes_wrong_mode_and_errors() -> eyre::Result<()> { + async fn recognizes_wrong_mode_and_does_not_error() -> eyre::Result<()> { let temp_dir = tempfile::tempdir()?; - let test_file = temp_dir.path().join("recognizes_wrong_mode_and_errors"); + let test_file = temp_dir + .path() + .join("recognizes_wrong_mode_and_does_not_error"); let initial_mode = 0o777; - let expected_mode = 0o000; + let expected_mode = 0o666; write(test_file.as_path(), "Some content").await?; tokio::fs::set_permissions(test_file.as_path(), PermissionsExt::from_mode(initial_mode)) .await?; - match CreateOrInsertIntoFile::plan( + let mut action = CreateOrInsertIntoFile::plan( test_file.clone(), None, None, @@ -477,19 +480,11 @@ mod test { "Some different content".into(), Position::End, ) - .await - { - Err(ActionError::PathModeMismatch(path, got, expected)) => { - assert_eq!(path, test_file.as_path()); - assert_eq!(expected, expected_mode); - assert_eq!(got, initial_mode); - }, - _ => { - return Err(eyre!( - "Should have returned an ActionError::PathModeMismatch error" - )) - }, - } + .await?; + + action.try_execute().await?; + + action.try_revert().await?; assert!(test_file.exists(), "File should have not been deleted"); diff --git a/src/action/common/configure_shell_profile.rs b/src/action/common/configure_shell_profile.rs index 0c593e1..1b93770 100644 --- a/src/action/common/configure_shell_profile.rs +++ b/src/action/common/configure_shell_profile.rs @@ -3,7 +3,6 @@ use crate::action::{Action, ActionDescription, ActionError, ActionTag, StatefulA use nix::unistd::User; use std::path::{Path, PathBuf}; -use target_lexicon::OperatingSystem; use tokio::task::JoinSet; use tracing::{span, Instrument, Span}; @@ -88,22 +87,12 @@ impl ConfigureShellProfile { ); continue; } - // Macs require a different mode on certain files... - let required_mode = match target_lexicon::OperatingSystem::host() { - OperatingSystem::MacOSX { - major: _, - minor: _, - patch: _, - } - | OperatingSystem::Darwin => 0o444, - _ => 0o644, - }; create_or_insert_files.push( CreateOrInsertIntoFile::plan( profile_target_path, None, None, - required_mode, + 0o644, shell_buf.to_string(), create_or_insert_into_file::Position::Beginning, )