Skip to content

Commit

Permalink
Add checking file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Dec 25, 2022
1 parent 407cbcc commit 7392728
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub fn is_different<A: AsRef<Path>, B: AsRef<Path>>(a_base: A, b_base: B) -> Res
if a.depth() != b.depth()
|| a.file_type() != b.file_type()
|| a.file_name() != b.file_name()
|| a.metadata()?.permissions() != b.metadata()?.permissions()
|| (a.file_type().is_file() && read_to_vec(a.path())? != read_to_vec(b.path())?)
{
return Ok(true);
Expand Down
Empty file added tests/permissions/bad/dir1/file
Empty file.
Empty file added tests/permissions/bad/dir2/file
Empty file.
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ fn reflexive() {
assert!(dir_diff::is_different("tests/reflexive/dir1", "tests/reflexive/dir2").unwrap());
}

#[test]
fn binary_permissions() {
assert!(!dir_diff::is_different("tests/permissions/good/dir1", "tests/permissions/good/dir2").unwrap());
assert!(dir_diff::is_different("tests/permissions/bad/dir1", "tests/permissions/bad/dir2").unwrap());
}

#[test]
fn dirs_differ() {
assert!(dir_diff::is_different("tests/dirs_differ/dir1", "tests/dirs_differ/dir2").unwrap());
Expand Down

0 comments on commit 7392728

Please sign in to comment.