Skip to content

Commit eafc75f

Browse files
etc-merge: Ignore mtime while comparing stat
Signed-off-by: Johan-Liebert1 <[email protected]>
1 parent d527926 commit eafc75f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

crates/etc-merge/src/lib.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use cap_std_ext::dirext::CapStdExtDirExt;
1919
use composefs::fsverity::{FsVerityHashValue, Sha256HashValue, Sha512HashValue};
2020
use composefs::generic_tree::{Directory, Inode, Leaf, LeafContent, Stat};
2121
use composefs::tree::ImageError;
22-
use rustix::fs::{AtFlags, Gid, Uid, XattrFlags, getxattr, listxattr, lsetxattr, readlinkat};
22+
use rustix::fs::{getxattr, listxattr, lsetxattr, readlinkat, AtFlags, Gid, Uid, XattrFlags};
2323

2424
#[derive(Debug)]
2525
struct CustomMetadata {
@@ -52,7 +52,7 @@ impl From<(&cap_std::fs::Metadata, Xattrs)> for MyStat {
5252
}
5353
}
5454

55-
fn stat_eq(this: &Stat, other: &Stat) -> bool {
55+
fn stat_eq_ignore_mtime(this: &Stat, other: &Stat) -> bool {
5656
if this.st_uid != other.st_uid {
5757
return false;
5858
}
@@ -65,10 +65,6 @@ fn stat_eq(this: &Stat, other: &Stat) -> bool {
6565
return false;
6666
}
6767

68-
if this.st_mtim_sec != other.st_mtim_sec {
69-
return false;
70-
}
71-
7268
if this.xattrs != other.xattrs {
7369
return false;
7470
}
@@ -97,8 +93,6 @@ fn collect_all_files(root: &Directory<CustomMetadata>, current_path: PathBuf) ->
9793

9894
if let Inode::Directory(dir) = inode {
9995
collect(dir, current_path.clone(), files);
100-
} else {
101-
// files.push(current_path.clone());
10296
}
10397

10498
current_path.pop();
@@ -183,7 +177,7 @@ fn get_modifications(
183177
Inode::Directory(curr_dir) => {
184178
match pristine.get_directory(path) {
185179
Ok(old_dir) => {
186-
if !stat_eq(&curr_dir.stat, &old_dir.stat) {
180+
if !stat_eq_ignore_mtime(&curr_dir.stat, &old_dir.stat) {
187181
// Directory permissions/owner modified
188182
diff.modified.push(current_path.clone());
189183
}
@@ -215,7 +209,7 @@ fn get_modifications(
215209
};
216210

217211
if old_meta.content_hash != current_meta.content_hash
218-
|| !stat_eq(&old_leaf.stat, &leaf.stat)
212+
|| !stat_eq_ignore_mtime(&old_leaf.stat, &leaf.stat)
219213
{
220214
// File modified in some way
221215
diff.modified.push(current_path.clone());

0 commit comments

Comments
 (0)