diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c index 1340484c..bbb3f11d 100644 --- a/src/libostree/ostree-repo-checkout.c +++ b/src/libostree/ostree-repo-checkout.c @@ -691,6 +691,22 @@ checkout_tree_at (OstreeRepo *self, } } + /* Set directory mtime to 0, so that it is constant for all checkouts. + * Must be done after setting permissions and creating all children. + */ + if (!did_exist) + { + const struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, } }; + do + res = futimens (destination_dfd, times); + while (G_UNLIKELY (res == -1 && errno == EINTR)); + if (G_UNLIKELY (res == -1)) + { + gs_set_error_from_errno (error, errno); + goto out; + } + } + /* Finally, fsync to ensure all entries are on disk. Ultimately * this should be configurable for the case where we're constructing * buildroots. diff --git a/tests/basic-test.sh b/tests/basic-test.sh index 106d9f12..007d7ced 100755 --- a/tests/basic-test.sh +++ b/tests/basic-test.sh @@ -347,6 +347,8 @@ else fi stat '--format=%Y' test2-checkout/baz/cow > cow-mtime assert_file_has_content cow-mtime 0 +stat '--format=%Y' test2-checkout/baz/deeper > deeper-mtime +assert_file_has_content deeper-mtime 0 echo "ok content mtime" cd ${test_tmpdir}