Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(module): Improve readalability in Copy #468

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rash_core/src/modules/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ fn change_permissions(
mode: u32,
check_mode: bool,
) -> Result<bool> {
let mut dest_permissions_copy = dest_permissions;
let masked_mode = mode & 0o7777;

// & 0o7777 to remove lead 100: 100644 -> 644
if dest_permissions_copy.mode() & 0o7777 != mode & 0o7777 {
if dest_permissions.mode() & 0o7777 != masked_mode {
if !check_mode {
trace!("changing mode: {:o}", &mode);
trace!("changing mode: {:o}", mode);
let mut dest_permissions_copy = dest_permissions;
dest_permissions_copy.set_mode(mode);
set_permissions(dest, dest_permissions_copy)?;
}
return Ok(true);
};
}
Ok(false)
}

Expand Down Expand Up @@ -153,7 +154,6 @@ pub fn copy_file(params: Params, check_mode: bool) -> Result<ModuleResult> {
.create(true)
.open(&params.dest)
} else {
// TODO: avoid this logic.
tempfile()
}
})?;
Expand Down
Loading